Skip to content

Commit

Permalink
mfd: Fix pcap_add_subdev error path
Browse files Browse the repository at this point in the history
1. return -ENOMEM if platform_device_alloc() fail.
2. call platform_device_put() if platform_device_add() fail.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
  • Loading branch information
Axel Lin authored and Samuel Ortiz committed Oct 28, 2010
1 parent b59cede commit 09ff21e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/mfd/ezx-pcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,20 @@ static int __devinit pcap_add_subdev(struct pcap_chip *pcap,
struct pcap_subdev *subdev)
{
struct platform_device *pdev;
int ret;

pdev = platform_device_alloc(subdev->name, subdev->id);
if (!pdev)
return -ENOMEM;

pdev->dev.parent = &pcap->spi->dev;
pdev->dev.platform_data = subdev->platform_data;

return platform_device_add(pdev);
ret = platform_device_add(pdev);
if (ret)
platform_device_put(pdev);

return ret;
}

static int __devexit ezx_pcap_remove(struct spi_device *spi)
Expand Down

0 comments on commit 09ff21e

Please sign in to comment.