Commit 52a3a374 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Lee Jones

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: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
parent 59f4d741
......@@ -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]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment