Skip to content

Commit

Permalink
[media] c8sectpfe: fix return of garbage
Browse files Browse the repository at this point in the history
The variable err was never initialized, that means we had been checking
a garbage value in the for loop. Moreover if the segment is not outside
the firmware file then also we have been returning the garbage.
Initialize it to 0 so that on success we return the value and no need to
check in the for loop also as it is initially 0 and whenever that value
changes we have done a break from the loop.

Signed-off-by: Sudip Mukherjee <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
sudipm-mukherjee authored and mchehab committed Oct 22, 2015
1 parent bf44722 commit 51a3ac5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ static int load_slim_core_fw(const struct firmware *fw, void *context)
Elf32_Ehdr *ehdr;
Elf32_Phdr *phdr;
u8 __iomem *dst;
int err, i;
int err = 0, i;

if (!fw || !context)
return -EINVAL;
Expand All @@ -1106,7 +1106,7 @@ static int load_slim_core_fw(const struct firmware *fw, void *context)
phdr = (Elf32_Phdr *)(fw->data + ehdr->e_phoff);

/* go through the available ELF segments */
for (i = 0; i < ehdr->e_phnum && !err; i++, phdr++) {
for (i = 0; i < ehdr->e_phnum; i++, phdr++) {

/* Only consider LOAD segments */
if (phdr->p_type != PT_LOAD)
Expand Down

0 comments on commit 51a3ac5

Please sign in to comment.