mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Fei Shao <fshao@chromium.org>
Cc: Stephen Boyd <sboyd@kernel.org>,
	Jerome Brunet <jbrunet@baylibre.com>,
	Michael Turquette <mturquette@baylibre.com>,
	linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] clk: Fix memory leak in devm_clk_notifier_register()
Date: Mon, 19 Jun 2023 11:48:36 +0300	[thread overview]
Message-ID: <35f6212e-69f8-432f-a5c8-99ed5c844f11@moroto.mountain> (raw)
In-Reply-To: <20230619112253.v2.1.I13f060c10549ef181603e921291bdea95f83033c@changeid>

On Mon, Jun 19, 2023 at 11:22:53AM +0800, Fei Shao wrote:
> devm_clk_notifier_register() allocates a devres resource for clk
> notifier but didn't register that to the device, so the notifier didn't
> get unregistered on device detach and the allocated resource was leaked.
> 
> Fix the issue by registering the resource through devres_add().
> 
> Fixes: 6d30d50d037d ("clk: add devm variant of clk_notifier_register")
> Signed-off-by: Fei Shao <fshao@chromium.org>
> ---
> 

Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>

How did you find this bug?

I can think of some ways to find this bug with static analysis.

KTODO: static analysis:  look at unused parameters

Both GCC and Clang have a warning for unused parameters.  I think the
last time I looked at GCC it had a lot of false positives for functions
which were called as pointers but hopefully that has been fixed now?
Smatch does not have a check for this.  If someone were to write it,
I would probably the check under the --pedantic flag so it would be
turned off by default.

regards,
dan carpenter


  reply	other threads:[~2023-06-19  8:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-19  3:22 Fei Shao
2023-06-19  8:48 ` Dan Carpenter [this message]
2023-06-19  9:05   ` Fei Shao
2023-06-19  9:24     ` Dan Carpenter
2023-06-19  9:38       ` Fei Shao
2023-06-19  9:57       ` Dan Carpenter
2023-06-19 10:34         ` Fei Shao
2023-06-20 19:03 ` Stephen Boyd

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=35f6212e-69f8-432f-a5c8-99ed5c844f11@moroto.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=fshao@chromium.org \
    --cc=jbrunet@baylibre.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@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

all inboxes | Powered by JetHome®