Skip to content

Commit

Permalink
shdma: fix initialization error handling
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dan Williams committed Nov 22, 2009
1 parent 49954c1 commit 56adf7e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions drivers/dma/shdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -722,7 +721,6 @@ static int __init sh_dmae_probe(struct platform_device *pdev)
rst_err:
kfree(shdev);

shdev_err:
return err;
}

Expand Down

0 comments on commit 56adf7e

Please sign in to comment.