public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Chanwoo Choi <cw00.choi@samsung.com>
To: "Gustavo A. R. Silva" <garsilva@embeddedor.com>,
	MyungJoo Ham <myungjoo.ham@samsung.com>,
	Kyungmin Park <kyungmin.park@samsung.com>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PM / devfreq: Remove unnecessary NULL check before kfree
Date: Mon, 13 Nov 2017 07:28:43 +0900	[thread overview]
Message-ID: <5A08CB1B.6000201@samsung.com> (raw)
In-Reply-To: <20171112082739.GA20464@embeddedor.com>

Hi,

On 2017년 11월 12일 17:27, Gustavo A. R. Silva wrote:
> NULL check before freeing functions like kfree is not needed.
> 
> This issue was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
>  drivers/devfreq/devfreq.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 78fb496..21164a9 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -672,8 +672,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
>  
>  	device_unregister(&devfreq->dev);
>  err_dev:
> -	if (devfreq)
> -		kfree(devfreq);
> +	kfree(devfreq);
>  err_out:
>  	return ERR_PTR(err);
>  }
> 

It prevents the memory leak when the registration
of devfreq device is failed. You can check the
detailed reason on patch1[1].

[1] PM / devfreq: Fix memory leak when fail to register device
- https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9e14de1077e9c34f141cf98bdba60cdd5193d962


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

      reply	other threads:[~2017-11-12 22:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20171112082944epcas5p216efba5e38d3bf17ee993abe51aa4dc3@epcas5p2.samsung.com>
2017-11-12  8:27 ` [PATCH] PM / devfreq: Remove unnecessary NULL check before kfree Gustavo A. R. Silva
2017-11-12 22:28   ` Chanwoo Choi [this message]

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=5A08CB1B.6000201@samsung.com \
    --to=cw00.choi@samsung.com \
    --cc=garsilva@embeddedor.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=myungjoo.ham@samsung.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