shdma: fix initialization error handling
1/ Error handling code following a kzalloc should free the allocated data. 2/ Report an error when no platform data is detected Both problems fixed by moving the platform data check before the allocation, and allows a goto to be killed. Reported-by: Julia Lawall <julia@diku.dk> Acked-by: Julia Lawall <julia@diku.dk> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
parent
49954c1567
commit
56adf7e812
1 changed files with 5 additions and 7 deletions
|
@ -640,17 +640,16 @@ static int __init sh_dmae_probe(struct platform_device *pdev)
|
||||||
#endif
|
#endif
|
||||||
struct sh_dmae_device *shdev;
|
struct sh_dmae_device *shdev;
|
||||||
|
|
||||||
|
/* get platform data */
|
||||||
|
if (!pdev->dev.platform_data)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
shdev = kzalloc(sizeof(struct sh_dmae_device), GFP_KERNEL);
|
shdev = kzalloc(sizeof(struct sh_dmae_device), GFP_KERNEL);
|
||||||
if (!shdev) {
|
if (!shdev) {
|
||||||
dev_err(&pdev->dev, "No enough memory\n");
|
dev_err(&pdev->dev, "No enough memory\n");
|
||||||
err = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto shdev_err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get platform data */
|
|
||||||
if (!pdev->dev.platform_data)
|
|
||||||
goto shdev_err;
|
|
||||||
|
|
||||||
/* platform data */
|
/* platform data */
|
||||||
memcpy(&shdev->pdata, pdev->dev.platform_data,
|
memcpy(&shdev->pdata, pdev->dev.platform_data,
|
||||||
sizeof(struct sh_dmae_pdata));
|
sizeof(struct sh_dmae_pdata));
|
||||||
|
@ -722,7 +721,6 @@ eirq_err:
|
||||||
rst_err:
|
rst_err:
|
||||||
kfree(shdev);
|
kfree(shdev);
|
||||||
|
|
||||||
shdev_err:
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue