]> git.baikalelectronics.ru Git - kernel.git/commit
regulator: palmas: Fix wrong kfree calls
authorAxel Lin <axel.lin@gmail.com>
Mon, 21 May 2012 12:55:40 +0000 (20:55 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 4 Jun 2012 09:42:49 +0000 (10:42 +0100)
commita21b9b92536a1f190331a83b8f3e5696af9cf114
tree3ea2ed05648bb232fa123923b666580621b8978e
parentb7dc9622e4c3808ef905a72fda997b5fc0c6f7d2
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>
drivers/regulator/palmas-regulator.c