aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma/shdma.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2009-11-22 14:10:10 -0500
committerDan Williams <dan.j.williams@intel.com>2009-11-22 14:10:10 -0500
commit56adf7e8127d601b172e180b44551ce83404348f (patch)
treeeabcdad1e4b17ea8f7c20a50a44ca859360085d3 /drivers/dma/shdma.c
parent49954c1567cb0d70d28bb5512d471dc5bd4e2c3f (diff)
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/shdma.c')
-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 b3b065c4e5c1..034ecf0ace03 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)
640#endif 640#endif
641 struct sh_dmae_device *shdev; 641 struct sh_dmae_device *shdev;
642 642
643 /* get platform data */
644 if (!pdev->dev.platform_data)
645 return -ENODEV;
646
643 shdev = kzalloc(sizeof(struct sh_dmae_device), GFP_KERNEL); 647 shdev = kzalloc(sizeof(struct sh_dmae_device), GFP_KERNEL);
644 if (!shdev) { 648 if (!shdev) {
645 dev_err(&pdev->dev, "No enough memory\n"); 649 dev_err(&pdev->dev, "No enough memory\n");
646 err = -ENOMEM; 650 return -ENOMEM;
647 goto shdev_err;
648 } 651 }
649 652
650 /* get platform data */
651 if (!pdev->dev.platform_data)
652 goto shdev_err;
653
654 /* platform data */ 653 /* platform data */
655 memcpy(&shdev->pdata, pdev->dev.platform_data, 654 memcpy(&shdev->pdata, pdev->dev.platform_data,
656 sizeof(struct sh_dmae_pdata)); 655 sizeof(struct sh_dmae_pdata));
@@ -722,7 +721,6 @@ eirq_err:
722rst_err: 721rst_err:
723 kfree(shdev); 722 kfree(shdev);
724 723
725shdev_err:
726 return err; 724 return err;
727} 725}
728 726