summaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>2018-03-14 22:47:55 +0100
committerLee Jones <lee.jones@linaro.org>2018-05-16 09:21:48 +0100
commit52a3a374af06121d6f704d1ab4fe4eeb8a1678a1 (patch)
tree331fe13d0ef35ff25c7467689840b50618b4f54f /drivers/mfd
parent59f4d741b15d45e68cdca63232ee8cd4224f2ccc (diff)
downloadlinux-52a3a374af06121d6f704d1ab4fe4eeb8a1678a1.tar.bz2
mfd: pcf50633: Fix some memory leaks in the error handling path of 'pcf50633_probe()'
If a 'platform_device_alloc()' call fails, we still need to release the resources that have already been allocated before returning. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/pcf50633-core.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c
index f952dff6765f..0d2a88d53eed 100644
--- a/drivers/mfd/pcf50633-core.c
+++ b/drivers/mfd/pcf50633-core.c
@@ -242,8 +242,10 @@ static int pcf50633_probe(struct i2c_client *client,
for (i = 0; i < PCF50633_NUM_REGULATORS; i++) {
pdev = platform_device_alloc("pcf50633-regulator", i);
- if (!pdev)
- return -ENOMEM;
+ if (!pdev) {
+ ret = -ENOMEM;
+ goto err2;
+ }
pdev->dev.parent = pcf->dev;
ret = platform_device_add_data(pdev, &pdata->reg_init_data[i],
@@ -269,6 +271,7 @@ static int pcf50633_probe(struct i2c_client *client,
err:
platform_device_put(pdev);
+err2:
for (j = 0; j < i; j++)
platform_device_put(pcf->regulator_pdev[j]);