* [PATCH] rtc: cpcap: kfreeing devm allocated memory
@ 2017-03-14 7:56 Dan Carpenter
2017-03-15 17:43 ` Sebastian Reichel
2017-03-16 22:01 ` Alexandre Belloni
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2017-03-14 7:56 UTC (permalink / raw)
To: Alessandro Zummo, Sebastian Reichel
Cc: Alexandre Belloni, rtc-linux, kernel-janitors
We shouldn't kfree(rtc) because is devm_ managed memory. It leads to a
double free.
Fixes: dd3bf50b35e3 ("rtc: cpcap: new rtc driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/rtc/rtc-cpcap.c b/drivers/rtc/rtc-cpcap.c
index 7c6a3c3167bd..5d163be98e9f 100644
--- a/drivers/rtc/rtc-cpcap.c
+++ b/drivers/rtc/rtc-cpcap.c
@@ -266,10 +266,8 @@ static int cpcap_rtc_probe(struct platform_device *pdev)
rtc->rtc_dev = devm_rtc_device_register(dev, "cpcap_rtc",
&cpcap_rtc_ops, THIS_MODULE);
- if (IS_ERR(rtc->rtc_dev)) {
- kfree(rtc);
+ if (IS_ERR(rtc->rtc_dev))
return PTR_ERR(rtc->rtc_dev);
- }
err = cpcap_get_vendor(dev, rtc->regmap, &rtc->vendor);
if (err)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] rtc: cpcap: kfreeing devm allocated memory
2017-03-14 7:56 [PATCH] rtc: cpcap: kfreeing devm allocated memory Dan Carpenter
@ 2017-03-15 17:43 ` Sebastian Reichel
2017-03-16 22:01 ` Alexandre Belloni
1 sibling, 0 replies; 3+ messages in thread
From: Sebastian Reichel @ 2017-03-15 17:43 UTC (permalink / raw)
To: Dan Carpenter
Cc: Alessandro Zummo, Alexandre Belloni, rtc-linux, kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 916 bytes --]
Hi,
On Tue, Mar 14, 2017 at 10:56:30AM +0300, Dan Carpenter wrote:
> We shouldn't kfree(rtc) because is devm_ managed memory. It leads to a
> double free.
>
> Fixes: dd3bf50b35e3 ("rtc: cpcap: new rtc driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/rtc/rtc-cpcap.c b/drivers/rtc/rtc-cpcap.c
> index 7c6a3c3167bd..5d163be98e9f 100644
> --- a/drivers/rtc/rtc-cpcap.c
> +++ b/drivers/rtc/rtc-cpcap.c
> @@ -266,10 +266,8 @@ static int cpcap_rtc_probe(struct platform_device *pdev)
> rtc->rtc_dev = devm_rtc_device_register(dev, "cpcap_rtc",
> &cpcap_rtc_ops, THIS_MODULE);
>
> - if (IS_ERR(rtc->rtc_dev)) {
> - kfree(rtc);
> + if (IS_ERR(rtc->rtc_dev))
> return PTR_ERR(rtc->rtc_dev);
> - }
>
> err = cpcap_get_vendor(dev, rtc->regmap, &rtc->vendor);
> if (err)
Acked-By: Sebastian Reichel <sre@kernel.org>
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] rtc: cpcap: kfreeing devm allocated memory
2017-03-14 7:56 [PATCH] rtc: cpcap: kfreeing devm allocated memory Dan Carpenter
2017-03-15 17:43 ` Sebastian Reichel
@ 2017-03-16 22:01 ` Alexandre Belloni
1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Belloni @ 2017-03-16 22:01 UTC (permalink / raw)
To: Dan Carpenter
Cc: Alessandro Zummo, Sebastian Reichel, rtc-linux, kernel-janitors
On 14/03/2017 at 10:56:30 +0300, Dan Carpenter wrote:
> We shouldn't kfree(rtc) because is devm_ managed memory. It leads to a
> double free.
>
> Fixes: dd3bf50b35e3 ("rtc: cpcap: new rtc driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
Applied, thanks.
--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-16 22:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-14 7:56 [PATCH] rtc: cpcap: kfreeing devm allocated memory Dan Carpenter
2017-03-15 17:43 ` Sebastian Reichel
2017-03-16 22:01 ` Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox