aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2009-11-22 12:10:10 -0700
committerDan Williams <dan.j.williams@intel.com>2009-11-22 12:10:10 -0700
commit56adf7e8127d601b172e180b44551ce83404348f (patch)
treeeabcdad1e4b17ea8f7c20a50a44ca859360085d3 /drivers/dma
parent49954c1567cb0d70d28bb5512d471dc5bd4e2c3f (diff)
downloadkernel_samsung_tuna-56adf7e8127d601b172e180b44551ce83404348f.zip
kernel_samsung_tuna-56adf7e8127d601b172e180b44551ce83404348f.tar.gz
kernel_samsung_tuna-56adf7e8127d601b172e180b44551ce83404348f.tar.bz2
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>
Diffstat (limited to 'drivers/dma')
-rw-r--r--drivers/dma/shdma.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/drivers/dma/shdma.c b/drivers/dma/shdma.c
index b3b065c..034ecf0 100644
--- a/drivers/dma/shdma.c
+++ b/drivers/dma/shdma.c
@@ -640,17 +640,16 @@ static int __init sh_dmae_probe(struct platform_device *pdev)
#endif
struct sh_dmae_device *shdev;
+ /* get platform data */
+ if (!pdev->dev.platform_data)
+ return -ENODEV;
+
shdev = kzalloc(sizeof(struct sh_dmae_device), GFP_KERNEL);
if (!shdev) {
dev_err(&pdev->dev, "No enough memory\n");
- err = -ENOMEM;
- goto shdev_err;
+ return -ENOMEM;
}
- /* get platform data */
- if (!pdev->dev.platform_data)
- goto shdev_err;
-
/* platform data */
memcpy(&shdev->pdata, pdev->dev.platform_data,
sizeof(struct sh_dmae_pdata));
@@ -722,7 +721,6 @@ eirq_err:
rst_err:
kfree(shdev);
-shdev_err:
return err;
}