mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-12-01 00:12:36 -05:00
mtd: fix memory leaks in phram_setup
There are two code paths in drivers/mtd/devices/phram.c::phram_setup() that will leak memory. Memory is allocated to the variable 'name' with kmalloc() by the parse_name() function, but if we leave by way of the parse_err() macro, then that memory is never kfree()'d, nor is it ever used with register_device() so it won't be freed later either - leak. Found by the Coverity checker as #593 - simple fix below. Signed-off-by: Jesper Juhl <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
This commit is contained in:
parent
e0c7d76753
commit
4f678a58d3
1 changed files with 6 additions and 2 deletions
|
|
@ -266,12 +266,16 @@ static int phram_setup(const char *val, struct kernel_param *kp)
|
|||
return 0;
|
||||
|
||||
ret = parse_num32(&start, token[1]);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
kfree(name);
|
||||
parse_err("illegal start address\n");
|
||||
}
|
||||
|
||||
ret = parse_num32(&len, token[2]);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
kfree(name);
|
||||
parse_err("illegal device length\n");
|
||||
}
|
||||
|
||||
register_device(name, start, len);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue