From: Dan Carpenter <dan.carpenter@oracle.com>
To: Alessandro Zummo <a.zummo@towertech.it>,
Sebastian Reichel <sre@kernel.org>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>,
rtc-linux@googlegroups.com, kernel-janitors@vger.kernel.org
Subject: [PATCH] rtc: cpcap: kfreeing devm allocated memory
Date: Tue, 14 Mar 2017 07:56:30 +0000 [thread overview]
Message-ID: <20170314075319.GB6111@mwanda> (raw)
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)
next reply other threads:[~2017-03-14 7:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-14 7:56 Dan Carpenter [this message]
2017-03-15 17:43 ` [PATCH] rtc: cpcap: kfreeing devm allocated memory Sebastian Reichel
2017-03-16 22:01 ` Alexandre Belloni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170314075319.GB6111@mwanda \
--to=dan.carpenter@oracle.com \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@free-electrons.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=rtc-linux@googlegroups.com \
--cc=sre@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox