Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] media, Micronas dvb-t: Fix mem leaks, don't needlessly zero mem, 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 <jj@chaosbits.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Jesper Juhl and committed by
Mauro Carvalho Chehab
8afe9119 9b67693c

+4 -2
+4 -2
drivers/media/dvb/frontends/drxd_hard.c
··· 909 909 return -EIO; 910 910 } 911 911 912 - state->microcode = kzalloc(fw->size, GFP_KERNEL); 912 + state->microcode = kmalloc(fw->size, GFP_KERNEL); 913 913 if (state->microcode == NULL) { 914 - printk(KERN_ERR "drxd: firmware load failure: nomemory\n"); 914 + release_firmware(fw); 915 + printk(KERN_ERR "drxd: firmware load failure: no memory\n"); 915 916 return -ENOMEM; 916 917 } 917 918 918 919 memcpy(state->microcode, fw->data, fw->size); 919 920 state->microcode_length = fw->size; 921 + release_firmware(fw); 920 922 return 0; 921 923 } 922 924