Skip to content

Commit

Permalink
[media] media, Micronas dvb-t: Fix mem leaks, don't needlessly zero m…
Browse files Browse the repository at this point in the history
…em, fix spelling

In drivers/media/dvb/frontends/drxd_hard.c::load_firmware() I see 3
small issues:

 1) When the 'fw' variable goes out of scope we'll leak the memory
 allocated to it by request_firmware() by neglecting to call
 release_firmware().

 2) After a successful request_firmware() we allocate fw->size bytes
 of memory using kzalloc() only to immediately overwrite all that
 memory with memcpy(), so asking for zeroed memory seems like wasted
 effort - just use kmalloc().

 3) In one of the error messages "no memory" lacks a space and is
 written as "nomemory".

This patch fixes all 3 issues.

Signed-off-by: Jesper Juhl <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
jjuhl authored and Mauro Carvalho Chehab committed Jul 27, 2011
1 parent 9b67693 commit 8afe911
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/media/dvb/frontends/drxd_hard.c
Original file line number Diff line number Diff line change
Expand Up @@ -909,14 +909,16 @@ static int load_firmware(struct drxd_state *state, const char *fw_name)
return -EIO;
}

state->microcode = kzalloc(fw->size, GFP_KERNEL);
state->microcode = kmalloc(fw->size, GFP_KERNEL);
if (state->microcode == NULL) {
printk(KERN_ERR "drxd: firmware load failure: nomemory\n");
release_firmware(fw);
printk(KERN_ERR "drxd: firmware load failure: no memory\n");
return -ENOMEM;
}

memcpy(state->microcode, fw->data, fw->size);
state->microcode_length = fw->size;
release_firmware(fw);
return 0;
}

Expand Down

0 comments on commit 8afe911

Please sign in to comment.