From: Dan Carpenter <dan.carpenter@linaro.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org
Subject: Re: [PATCH 2/2] thermal/drivers/mediatek/lvts_thermal: Improve some memory allocation
Date: Tue, 9 Apr 2024 09:22:14 +0300 [thread overview]
Message-ID: <483b8e9a-26db-45c8-ada6-e39575760c51@moroto.mountain> (raw)
In-Reply-To: <4ebbe227-38b1-4a1c-af34-9ba7bdfecad5@wanadoo.fr>
On Mon, Apr 08, 2024 at 08:41:26PM +0200, Christophe JAILLET wrote:
> Le 08/04/2024 à 10:09, Dan Carpenter a écrit :
> > On Sun, Apr 07, 2024 at 10:01:49PM +0200, Christophe JAILLET wrote:
> > > diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
> > > index 3003dc350766..b133f731c5ba 100644
> > > --- a/drivers/thermal/mediatek/lvts_thermal.c
> > > +++ b/drivers/thermal/mediatek/lvts_thermal.c
> > > @@ -204,7 +204,7 @@ static const struct debugfs_reg32 lvts_regs[] = {
> > > static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)
> > > {
> > > - struct debugfs_regset32 *regset;
> > > + struct debugfs_regset32 *regsets;
> > > struct lvts_ctrl *lvts_ctrl;
> > > struct dentry *dentry;
> > > char name[64];
> > > @@ -214,8 +214,14 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)
> > > if (IS_ERR(lvts_td->dom_dentry))
> > > return 0;
> > > + regsets = devm_kcalloc(dev, lvts_td->num_lvts_ctrl,
> > > + sizeof(*regsets), GFP_KERNEL);
> > > + if (!regsets)
> > > + return 0;
> >
> > I understand that this preserved the behavior from the original code,
> > but the original code was wrong. This should return -ENOMEM.
>
> Hi Dan,
> I don't agree.
>
> For me, this memory allocation is of the same type as all debugfs functions
> that we ignore the error code.
>
> If it fails, it is not a reason good enough to have the probe fail. (anyway,
> if we are short on memory at this point other errors will likely occur)
>
Huh. It's an interesting point. Fair enough.
> >
> > > +
> > > for (i = 0; i < lvts_td->num_lvts_ctrl; i++) {
> > > + struct debugfs_regset32 *regset = ®sets[i];
> > > lvts_ctrl = &lvts_td->lvts_ctrl[i];
> >
> > The blank line should come after the declaration.
>
> The blank line was already there, and in this file, it looks like the
> preferred style (even if not completely consistent)
>
> Let see if there is some comment about 0 or -ENOMEM in case of memory
> allocation error, and if needed, I'll repost without the blank line.
>
There is supposed to be a blank line after declarations though so I
think if you re-run checkpatch.pl -f on the file there is a checkpatch
warning now.
regards,
dan carpenter
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
prev parent reply other threads:[~2024-04-09 6:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-07 20:01 [PATCH 1/2] thermal/drivers/mediatek/lvts_thermal: Make debugfs related fields more consistent Christophe JAILLET
2024-04-07 20:01 ` [PATCH 2/2] thermal/drivers/mediatek/lvts_thermal: Improve some memory allocation Christophe JAILLET
2024-04-08 8:09 ` Dan Carpenter
2024-04-08 18:41 ` Christophe JAILLET
2024-04-09 6:22 ` Dan Carpenter [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=483b8e9a-26db-45c8-ada6-e39575760c51@moroto.mountain \
--to=dan.carpenter@linaro.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=daniel.lezcano@linaro.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=matthias.bgg@gmail.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.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