mirror of
https://github.com/S3NEO/android_kernel_samsung_msm8226.git
synced 2024-11-07 03:47:13 +00:00
regulator: Fix memory leak in max8998_pmic_probe failure path
Signed-off-by: Axel Lin <axel.lin@gmail.com> Acked-by: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
This commit is contained in:
parent
77fa44d0e1
commit
6be6e96fe9
1 changed files with 13 additions and 9 deletions
|
@ -732,13 +732,15 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
|
||||||
if (!pdata->buck1_set1) {
|
if (!pdata->buck1_set1) {
|
||||||
printk(KERN_ERR "MAX8998 SET1 GPIO defined as 0 !\n");
|
printk(KERN_ERR "MAX8998 SET1 GPIO defined as 0 !\n");
|
||||||
WARN_ON(!pdata->buck1_set1);
|
WARN_ON(!pdata->buck1_set1);
|
||||||
return -EIO;
|
ret = -EIO;
|
||||||
|
goto err_free_mem;
|
||||||
}
|
}
|
||||||
/* Check if SET2 is not equal to 0 */
|
/* Check if SET2 is not equal to 0 */
|
||||||
if (!pdata->buck1_set2) {
|
if (!pdata->buck1_set2) {
|
||||||
printk(KERN_ERR "MAX8998 SET2 GPIO defined as 0 !\n");
|
printk(KERN_ERR "MAX8998 SET2 GPIO defined as 0 !\n");
|
||||||
WARN_ON(!pdata->buck1_set2);
|
WARN_ON(!pdata->buck1_set2);
|
||||||
return -EIO;
|
ret = -EIO;
|
||||||
|
goto err_free_mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
gpio_request(pdata->buck1_set1, "MAX8998 BUCK1_SET1");
|
gpio_request(pdata->buck1_set1, "MAX8998 BUCK1_SET1");
|
||||||
|
@ -758,7 +760,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
|
||||||
max8998->buck1_vol[0] = i;
|
max8998->buck1_vol[0] = i;
|
||||||
ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE1, i);
|
ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE1, i);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
goto err_free_mem;
|
||||||
|
|
||||||
/* Set predefined value for BUCK1 register 2 */
|
/* Set predefined value for BUCK1 register 2 */
|
||||||
i = 0;
|
i = 0;
|
||||||
|
@ -770,7 +772,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
|
||||||
max8998->buck1_vol[1] = i;
|
max8998->buck1_vol[1] = i;
|
||||||
ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE2, i);
|
ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE2, i);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
goto err_free_mem;
|
||||||
|
|
||||||
/* Set predefined value for BUCK1 register 3 */
|
/* Set predefined value for BUCK1 register 3 */
|
||||||
i = 0;
|
i = 0;
|
||||||
|
@ -782,7 +784,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
|
||||||
max8998->buck1_vol[2] = i;
|
max8998->buck1_vol[2] = i;
|
||||||
ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE3, i);
|
ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE3, i);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
goto err_free_mem;
|
||||||
|
|
||||||
/* Set predefined value for BUCK1 register 4 */
|
/* Set predefined value for BUCK1 register 4 */
|
||||||
i = 0;
|
i = 0;
|
||||||
|
@ -794,7 +796,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
|
||||||
max8998->buck1_vol[3] = i;
|
max8998->buck1_vol[3] = i;
|
||||||
ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE4, i);
|
ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE4, i);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
goto err_free_mem;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -803,7 +805,8 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
|
||||||
if (!pdata->buck2_set3) {
|
if (!pdata->buck2_set3) {
|
||||||
printk(KERN_ERR "MAX8998 SET3 GPIO defined as 0 !\n");
|
printk(KERN_ERR "MAX8998 SET3 GPIO defined as 0 !\n");
|
||||||
WARN_ON(!pdata->buck2_set3);
|
WARN_ON(!pdata->buck2_set3);
|
||||||
return -EIO;
|
ret = -EIO;
|
||||||
|
goto err_free_mem;
|
||||||
}
|
}
|
||||||
gpio_request(pdata->buck2_set3, "MAX8998 BUCK2_SET3");
|
gpio_request(pdata->buck2_set3, "MAX8998 BUCK2_SET3");
|
||||||
gpio_direction_output(pdata->buck2_set3,
|
gpio_direction_output(pdata->buck2_set3,
|
||||||
|
@ -818,7 +821,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
|
||||||
max8998->buck2_vol[0] = i;
|
max8998->buck2_vol[0] = i;
|
||||||
ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE1, i);
|
ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE1, i);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
goto err_free_mem;
|
||||||
|
|
||||||
/* BUCK2 register 2 */
|
/* BUCK2 register 2 */
|
||||||
i = 0;
|
i = 0;
|
||||||
|
@ -830,7 +833,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
|
||||||
max8998->buck2_vol[1] = i;
|
max8998->buck2_vol[1] = i;
|
||||||
ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE2, i);
|
ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE2, i);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
goto err_free_mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < pdata->num_regulators; i++) {
|
for (i = 0; i < pdata->num_regulators; i++) {
|
||||||
|
@ -860,6 +863,7 @@ err:
|
||||||
if (rdev[i])
|
if (rdev[i])
|
||||||
regulator_unregister(rdev[i]);
|
regulator_unregister(rdev[i]);
|
||||||
|
|
||||||
|
err_free_mem:
|
||||||
kfree(max8998->rdev);
|
kfree(max8998->rdev);
|
||||||
kfree(max8998);
|
kfree(max8998);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue