aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/pcf50633-core.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2009-10-13 18:12:33 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2009-12-13 13:21:17 -0500
commit68d641efd86d901d000b888eeab5481257d49f12 (patch)
treea916769e71d50c0d20725cad60fb0402da198692 /drivers/mfd/pcf50633-core.c
parentb18fdc4b3e5e418e5582f5403c8a05b2c67eea16 (diff)
mfd: Fix memleak in pcf50633_client_dev_register
Since platform_device_add_data copies the passed data, the allocated subdev_pdata is never freed. A simple fix would be to either free subdev_pdata or put it onto the stack. But since the pcf50633 child devices can rely on beeing children of the pcf50633 core device it's much more elegant to get access to pcf50633 core structure through that link. This allows to get completly rid of pcf5033_subdev_pdata. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/pcf50633-core.c')
-rw-r--r--drivers/mfd/pcf50633-core.c10
1 files changed, 0 insertions, 10 deletions
diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c
index 48776d3018ed..69cdbdcd2e82 100644
--- a/drivers/mfd/pcf50633-core.c
+++ b/drivers/mfd/pcf50633-core.c
@@ -456,7 +456,6 @@ static void
456pcf50633_client_dev_register(struct pcf50633 *pcf, const char *name, 456pcf50633_client_dev_register(struct pcf50633 *pcf, const char *name,
457 struct platform_device **pdev) 457 struct platform_device **pdev)
458{ 458{
459 struct pcf50633_subdev_pdata *subdev_pdata;
460 int ret; 459 int ret;
461 460
462 *pdev = platform_device_alloc(name, -1); 461 *pdev = platform_device_alloc(name, -1);
@@ -465,15 +464,6 @@ pcf50633_client_dev_register(struct pcf50633 *pcf, const char *name,
465 return; 464 return;
466 } 465 }
467 466
468 subdev_pdata = kmalloc(sizeof(*subdev_pdata), GFP_KERNEL);
469 if (!subdev_pdata) {
470 dev_err(pcf->dev, "Error allocating subdev pdata\n");
471 platform_device_put(*pdev);
472 }
473
474 subdev_pdata->pcf = pcf;
475 platform_device_add_data(*pdev, subdev_pdata, sizeof(*subdev_pdata));
476
477 (*pdev)->dev.parent = pcf->dev; 467 (*pdev)->dev.parent = pcf->dev;
478 468
479 ret = platform_device_add(*pdev); 469 ret = platform_device_add(*pdev);