MIPS: TXx9: Fix error handling.
Error handling code following a kzalloc should free the allocated data. Error handling code following an ioremap should iounmap the allocated data. The semantic match that finds the first problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // <smpl> @r exists@ local idexpression x; statement S; expression E; identifier f,f1,l; position p1,p2; expression *ptr != NULL; @@ x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...); ... if (x == NULL) S <... when != x when != if (...) { <+...x...+> } ( x->f1 = E | (x->f1 == NULL || ...) | f(...,x->f1,...) ) ...> ( return \(0\|<+...x...+>\|ptr\); | return@p2 ...; ) @script:python@ p1 << r.p1; p2 << r.p2; @@ print "* file: %s kmalloc %s return %s" % (p1[0].file,p1[0].line,p2[0].line) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:
Родитель
13680ade4e
Коммит
70ebadc8e3
|
@ -782,7 +782,7 @@ void __init txx9_iocled_init(unsigned long baseaddr,
|
|||
return;
|
||||
iocled->mmioaddr = ioremap(baseaddr, 1);
|
||||
if (!iocled->mmioaddr)
|
||||
return;
|
||||
goto out_free;
|
||||
iocled->chip.get = txx9_iocled_get;
|
||||
iocled->chip.set = txx9_iocled_set;
|
||||
iocled->chip.direction_input = txx9_iocled_dir_in;
|
||||
|
@ -791,13 +791,13 @@ void __init txx9_iocled_init(unsigned long baseaddr,
|
|||
iocled->chip.base = basenum;
|
||||
iocled->chip.ngpio = num;
|
||||
if (gpiochip_add(&iocled->chip))
|
||||
return;
|
||||
goto out_unmap;
|
||||
if (basenum < 0)
|
||||
basenum = iocled->chip.base;
|
||||
|
||||
pdev = platform_device_alloc("leds-gpio", basenum);
|
||||
if (!pdev)
|
||||
return;
|
||||
goto out_gpio;
|
||||
iocled->pdata.num_leds = num;
|
||||
iocled->pdata.leds = iocled->leds;
|
||||
for (i = 0; i < num; i++) {
|
||||
|
@ -812,7 +812,16 @@ void __init txx9_iocled_init(unsigned long baseaddr,
|
|||
}
|
||||
pdev->dev.platform_data = &iocled->pdata;
|
||||
if (platform_device_add(pdev))
|
||||
platform_device_put(pdev);
|
||||
goto out_pdev;
|
||||
return;
|
||||
out_pdev:
|
||||
platform_device_put(pdev);
|
||||
out_gpio:
|
||||
gpio_remove(&iocled->chip);
|
||||
out_unmap:
|
||||
iounmap(iocled->mmioaddr);
|
||||
out_free:
|
||||
kfree(iocled);
|
||||
}
|
||||
#else /* CONFIG_LEDS_GPIO */
|
||||
void __init txx9_iocled_init(unsigned long baseaddr,
|
||||
|
|
Загрузка…
Ссылка в новой задаче