2013-03-28 00:52:14

by Andrei Epure

[permalink] [raw]
Subject: [PATCH 21/21] power: fix invalid free of devm_ allocated data

The objects allocated by devm_* APIs are managed by devres and are freed when
the device is detached. Hence there is no need to use kfree() explicitly.
Patch found using coccinelle.

Signed-off-by: Andrei Epure <[email protected]>
---
drivers/power/88pm860x_charger.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/power/88pm860x_charger.c b/drivers/power/88pm860x_charger.c
index 4b37a5a..36fb4b5 100644
--- a/drivers/power/88pm860x_charger.c
+++ b/drivers/power/88pm860x_charger.c
@@ -714,7 +714,6 @@ out_irq:
while (--i >= 0)
free_irq(info->irq[i], info);
out:
- kfree(info);
return ret;
}

@@ -728,7 +727,6 @@ static int pm860x_charger_remove(struct platform_device *pdev)
free_irq(info->irq[0], info);
for (i = 0; i < info->irq_nums; i++)
free_irq(info->irq[i], info);
- kfree(info);
return 0;
}

--
1.7.9.5


2013-04-01 06:47:12

by Anton Vorontsov

[permalink] [raw]
Subject: Re: [PATCH 21/21] power: fix invalid free of devm_ allocated data

On Thu, Mar 28, 2013 at 02:51:59AM +0200, Andrei Epure wrote:
> The objects allocated by devm_* APIs are managed by devres and are freed when
> the device is detached. Hence there is no need to use kfree() explicitly.
> Patch found using coccinelle.
>
> Signed-off-by: Andrei Epure <[email protected]>
> ---

Jingoo Han sent a similar change ealier... but thanks anyway!

Anton