Linux RTC
 help / color / mirror / Atom feed
From: Sebastian Reichel <sre@kernel.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>,
	rtc-linux@googlegroups.com, kernel-janitors@vger.kernel.org
Subject: [rtc-linux] Re: [PATCH] rtc: cpcap: kfreeing devm allocated memory
Date: Wed, 15 Mar 2017 18:43:38 +0100	[thread overview]
Message-ID: <20170315174337.4osgmj2reiw7v6pe@earth> (raw)
In-Reply-To: <20170314075319.GB6111@mwanda>

[-- Attachment #1: Type: text/plain, Size: 1402 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

-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2017-03-15 17:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-14  7:56 [rtc-linux] [PATCH] rtc: cpcap: kfreeing devm allocated memory Dan Carpenter
2017-03-15 17:43 ` Sebastian Reichel [this message]
2017-03-16 22:01 ` [rtc-linux] " 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=20170315174337.4osgmj2reiw7v6pe@earth \
    --to=sre@kernel.org \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=rtc-linux@googlegroups.com \
    /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