aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/devices
diff options
context:
space:
mode:
authorJesper Juhl <jesper.juhl@gmail.com>2006-05-13 19:42:25 -0400
committerDavid Woodhouse <dwmw2@infradead.org>2006-05-13 20:21:31 -0400
commita6550e57f9d074511cf420bdb802ab5e56edc3bb (patch)
tree56010126c6a1660b6fbd97765c73f8808214f98c /drivers/mtd/devices
parent552d9205186428a1e2a49ed577bcbba9f777af37 (diff)
mtd: fix memory leak in block2mtd_setup()
There's a mem leak in drivers/mtd/devices/block2mtd.c::block2mtd_setup() We can leak 'name' allocated with kmalloc in 'parse_name' if leave via the 'parse_err' macro since it contains a return but doesn't do any freeing. Spotted by coverity checker as bug 615. Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'drivers/mtd/devices')
-rw-r--r--drivers/mtd/devices/block2mtd.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index f54e4bf9b968..45606921364b 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -429,7 +429,8 @@ static inline void kill_final_newline(char *str)
429 429
430static int block2mtd_setup(const char *val, struct kernel_param *kp) 430static int block2mtd_setup(const char *val, struct kernel_param *kp)
431{ 431{
432 char buf[80+12], *str=buf; /* 80 for device, 12 for erase size */ 432 char buf[80+12]; /* 80 for device, 12 for erase size */
433 char *str = buf;
433 char *token[2]; 434 char *token[2];
434 char *name; 435 char *name;
435 size_t erase_size = PAGE_SIZE; 436 size_t erase_size = PAGE_SIZE;
@@ -441,7 +442,7 @@ static int block2mtd_setup(const char *val, struct kernel_param *kp)
441 strcpy(str, val); 442 strcpy(str, val);
442 kill_final_newline(str); 443 kill_final_newline(str);
443 444
444 for (i=0; i<2; i++) 445 for (i = 0; i < 2; i++)
445 token[i] = strsep(&str, ","); 446 token[i] = strsep(&str, ",");
446 447
447 if (str) 448 if (str)
@@ -460,8 +461,10 @@ static int block2mtd_setup(const char *val, struct kernel_param *kp)
460 461
461 if (token[1]) { 462 if (token[1]) {
462 ret = parse_num(&erase_size, token[1]); 463 ret = parse_num(&erase_size, token[1]);
463 if (ret) 464 if (ret) {
465 kfree(name);
464 parse_err("illegal erase size"); 466 parse_err("illegal erase size");
467 }
465 } 468 }
466 469
467 add_device(name, erase_size); 470 add_device(name, erase_size);