From: Stephen Boyd <sboyd@kernel.org>
To: Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
xkernel.wang@foxmail.com
Cc: Neil Armstrong <narmstrong@baylibre.com>,
jbrunet@baylibre.com, mturquette@baylibre.com,
khilman@baylibre.com, p.zabel@pengutronix.de,
linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] clk: meson: meson8b: fix a memory leak in meson8b_clkc_init_common()
Date: Fri, 22 Apr 2022 19:25:39 -0700 [thread overview]
Message-ID: <20220423022541.B12F3C385A0@smtp.kernel.org> (raw)
In-Reply-To: <CAFBinCC=Dp4bXT9sbmT=ZTiVfC1Mj=oRVxeDXfKbDczq45iekQ@mail.gmail.com>
Quoting Martin Blumenstingl (2022-04-18 09:39:57)
> Hello,
>
> first of all: thank you for this patch!
>
> On Thu, Apr 7, 2022 at 11:28 AM <xkernel.wang@foxmail.com> wrote:
> >
> > From: Xiaoke Wang <xkernel.wang@foxmail.com>
> >
> > `rstc` is allocated by kzalloc() for resetting the controller register,
> > however, if reset_controller_register() fails, `rstc` is not properly
> > released before returning, which can lead to memory leak.
> > Therefore, this patch adds kfree(rstc) on the above error path.
> In general I am fine with this approach. There's some more "return"
> statements below. Should these be covered as well?
Probably!
>
> Also a note about meson8b_clkc_init_common() itself: failures in that
> function will result in a non-working system.
> If we can't register the reset controller then most devices won't
> probe and CPU SMP cannot work.
> If registering any clock or the clock controller doesn't work then the
> system also won't work as clocks are not available to other drivers.
> So freeing memory in case of an error is good to have, but the end
> result is still the same: the system won't work.
>
Can we get far enough to record this fact into either a pstore ramoops
location or the serial console? That would be ideal to make debugging
early problems easier.
next prev parent reply other threads:[~2022-04-23 2:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-07 9:28 [PATCH] clk: meson: meson8b: fix a memory leak in meson8b_clkc_init_common() xkernel.wang
2022-04-07 10:05 ` Philipp Zabel
2022-04-18 16:39 ` Martin Blumenstingl
2022-04-23 2:25 ` Stephen Boyd [this message]
2022-04-24 19:36 ` Martin Blumenstingl
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=20220423022541.B12F3C385A0@smtp.kernel.org \
--to=sboyd@kernel.org \
--cc=jbrunet@baylibre.com \
--cc=khilman@baylibre.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=mturquette@baylibre.com \
--cc=narmstrong@baylibre.com \
--cc=p.zabel@pengutronix.de \
--cc=xkernel.wang@foxmail.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