All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@kernel.org>
To: zhou1615@umn.edu
Cc: kjlu@umn.edu, Dinh Nguyen <dinguyen@kernel.org>,
	Michael Turquette <mturquette@baylibre.com>,
	linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] clk: socfpga: Fix a memory leak bug in socfpga_gate_init()
Date: Mon, 24 Jan 2022 11:53:39 -0800	[thread overview]
Message-ID: <20220124195341.50C97C340E5@smtp.kernel.org> (raw)
In-Reply-To: <20220124165316.55449-1-zhou1615@umn.edu>

Quoting Zhou Qingyang (2022-01-24 08:53:16)
> diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c
> index 53d6e3ec4309..0ca5e0000925 100644
> --- a/drivers/clk/socfpga/clk-gate.c
> +++ b/drivers/clk/socfpga/clk-gate.c
> @@ -188,8 +188,10 @@ void __init socfpga_gate_init(struct device_node *node)
>                 return;
>  
>         ops = kmemdup(&gateclk_ops, sizeof(gateclk_ops), GFP_KERNEL);
> -       if (WARN_ON(!ops))
> +       if (WARN_ON(!ops)) {

A WARN_ON() after an allocation failure will lead to double stacktraces.
Can you remove the WARN_ON()?

Furthermore, it looks like 'ops' is never freed on failure in this
function. Did the SA tool figure that out? There are more problems with
this function and error paths. Seems like nobody cares.

> +               kfree(socfpga_clk);
>                 return;
> +       }
>

  reply	other threads:[~2022-01-24 20:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-24 16:53 [PATCH] clk: socfpga: Fix a memory leak bug in socfpga_gate_init() Zhou Qingyang
2022-01-24 19:53 ` Stephen Boyd [this message]
2022-01-25 19:32   ` Dinh Nguyen
2022-01-28 10:19 ` Greg KH

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=20220124195341.50C97C340E5@smtp.kernel.org \
    --to=sboyd@kernel.org \
    --cc=dinguyen@kernel.org \
    --cc=kjlu@umn.edu \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=zhou1615@umn.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.