aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-05-21 08:55:40 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-06-04 05:42:49 -0400
commitc71c8fd4daa342ba714090586a55fc5db7eaa275 (patch)
tree3ea2ed05648bb232fa123923b666580621b8978e /drivers/regulator
parentf8f5701bdaf9134b1f90e5044a82c66324d2073f (diff)
regulator: palmas: Fix wrong kfree calls
The devm_kzalloc function eliminates the need for manual resource releasing and simplify error handling. Resources allocated by devm_* are freed automatically on driver detach. Thus adding kfree calls here will introduce double free bug. The memory of desc array and the pointers to the rdev[] are allocated by devm_kzalloc call for struct palmas_pmic. struct palmas_pmic { struct palmas *palmas; struct device *dev; struct regulator_desc desc[PALMAS_NUM_REGS]; struct regulator_dev *rdev[PALMAS_NUM_REGS]; struct mutex mutex; int smps123; int smps457; int range[PALMAS_REG_SMPS10]; }; Which means we should not call kfree for pmic->rdev and pmic->desc. Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/palmas-regulator.c7
1 files changed, 0 insertions, 7 deletions
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
index c4435f608df7..9b7ca90057d5 100644
--- a/drivers/regulator/palmas-regulator.c
+++ b/drivers/regulator/palmas-regulator.c
@@ -775,9 +775,6 @@ static __devinit int palmas_probe(struct platform_device *pdev)
775err_unregister_regulator: 775err_unregister_regulator:
776 while (--id >= 0) 776 while (--id >= 0)
777 regulator_unregister(pmic->rdev[id]); 777 regulator_unregister(pmic->rdev[id]);
778 kfree(pmic->rdev);
779 kfree(pmic->desc);
780 kfree(pmic);
781 return ret; 778 return ret;
782} 779}
783 780
@@ -788,10 +785,6 @@ static int __devexit palmas_remove(struct platform_device *pdev)
788 785
789 for (id = 0; id < PALMAS_NUM_REGS; id++) 786 for (id = 0; id < PALMAS_NUM_REGS; id++)
790 regulator_unregister(pmic->rdev[id]); 787 regulator_unregister(pmic->rdev[id]);
791
792 kfree(pmic->rdev);
793 kfree(pmic->desc);
794 kfree(pmic);
795 return 0; 788 return 0;
796} 789}
797 790