clk: Fix memory leak in devm_clk_notifier_register()

Message ID 20230617160901.1.I2b151cdf7a72d9e3ecc7ab2ff38409ebe6d65d6b@changeid
State New
Headers
Series clk: Fix memory leak in devm_clk_notifier_register() |

Commit Message

Fei Shao June 17, 2023, 8:09 a.m. UTC
  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.

This fixes the issue.

Fixes: 6d30d50d037d ("clk: add devm variant of clk_notifier_register")
Signed-off-by: Fei Shao <fshao@chromium.org>
---

 drivers/clk/clk.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Fei Shao June 19, 2023, 3:56 a.m. UTC | #1
On Sun, Jun 18, 2023 at 4:06 AM Markus Elfring <Markus.Elfring@web.de> wrote:
>
> > This fixes the issue.
>
> Please replace this sentence by an imperative change suggestion.
>
> See also:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.4-rc6#n94
>
> Regards,
> Markus

Thanks for the feedback. I just sent v2.

Regards,
Fei
  
Dan Carpenter June 19, 2023, 5:27 a.m. UTC | #2
On Mon, Jun 19, 2023 at 11:56:56AM +0800, Fei Shao wrote:
> On Sun, Jun 18, 2023 at 4:06 AM Markus Elfring <Markus.Elfring@web.de> wrote:
> >
> > > This fixes the issue.
> >
> > Please replace this sentence by an imperative change suggestion.
> >
> > See also:
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.4-rc6#n94
> >
> > Regards,
> > Markus
> 
> Thanks for the feedback. I just sent v2.

Markus is banned from vger lists...  He doesn't have a very accurate
perspective of what is important and what is not important.

regards,
dan carpenter
  
Dan Carpenter June 19, 2023, 8:32 a.m. UTC | #3
On Mon, Jun 19, 2023 at 09:42:37AM +0200, Markus Elfring wrote:
> > He doesn't have a very accurate perspective
> > of what is important and what is not important.
> 
> I offered various hints for desirable change possibilities.
> The change acceptance might evolve in more constructive ways, doesn't it?

No, I'm sorry, it's not constructive at all.  You're just creating noise
when we should be looking at if the patch is correct and how we can
improve our QC infrastructure to prevent bugs like this in the future.

regards,
dan carpenter
  
Dan Carpenter June 19, 2023, 9:30 a.m. UTC | #4
Markus you always answer every email with more questions instead of
just listening to what I am saying.  This is why you were banned.

Even though you are banned, I encourage people to merge your patches
if they fix bugs.  And if your review comments are about bugs then they
are welcome.  If they are about coding style or grammar then they are
distracting.

I know that you are going to ask more questions but I am not going to
respond further.

regards,
dan carpenter
  

Patch

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 7ac9f7a8cb84..c249f9791ae8 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -4741,6 +4741,7 @@  int devm_clk_notifier_register(struct device *dev, struct clk *clk,
 	if (!ret) {
 		devres->clk = clk;
 		devres->nb = nb;
+		devres_add(dev, devres);
 	} else {
 		devres_free(devres);
 	}