From: Guru Das Srinagesh <linux@gurudas.dev>
To: David Laight <david.laight.linux@gmail.com>
Cc: Ovidiu Panait <ovidiu.panait.oss@gmail.com>,
rafael@kernel.org, daniel.lezcano@kernel.org,
rui.zhang@intel.com, lukasz.luba@arm.com,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] thermal: testing: Avoid NULL pointer dereference on missing arg
Date: Sun, 7 Jun 2026 12:55:13 -0700 [thread overview]
Message-ID: <aiXMoaYaRlTsMwqd@gurudas.dev> (raw)
In-Reply-To: <20260607122318.40696a11@pumpkin>
On Sun, Jun 07, 2026 at 12:23:18PM +0100, David Laight wrote:
> On Sat, 6 Jun 2026 19:52:49 -0700
> Guru Das Srinagesh <linux@gurudas.dev> wrote:
>
> > On Sun, Jun 07, 2026 at 12:04:18AM +0300, Ovidiu Panait wrote:
> > [...]
> > > To fix this, make arg an empty string instead of leaving it NULL when the
> > > separator is missing. sscanf() then fails correctly with -EINVAL on it.
> > [...]
> > > ---
> > > drivers/thermal/testing/command.c | 2 ++
> > > 1 file changed, 2 insertions(+)
> > >
> > > diff --git a/drivers/thermal/testing/command.c b/drivers/thermal/testing/command.c
> > > index 1159ecea57e7..5513a26feed7 100644
> > > --- a/drivers/thermal/testing/command.c
> > > +++ b/drivers/thermal/testing/command.c
> > > @@ -150,6 +150,8 @@ static ssize_t tt_command_process(char *s)
> > > if (arg) {
> > > *arg = '\0';
> > > arg++;
> > > + } else {
> > > + arg = s + strlen(s);
> > > }
> >
> > Here, `arg` is made to point to the NUL terminator of s. Couldn't this be simplified to:
> >
> > arg = "";
> >
> > to make the intent clearer? Since `tt_command_exec()` takes in arg as `const char *`,
> > pointing `arg` to a string literal is fine.
> >
>
> Except that 'arg' itself must be 'char *' otherwise the '*arg = 0'
> higher up will fail.
Sorry, could you please clarify the concern further?
`arg` is already `char *` (line 144), and I verified that my suggestion compiles fine.
next prev parent reply other threads:[~2026-06-07 20:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-06 21:04 [PATCH 1/3] thermal: testing: Avoid NULL pointer dereference on missing arg Ovidiu Panait
2026-06-06 21:04 ` [PATCH 2/3] thermal: testing: Replace sscanf() with kstrtoint() Ovidiu Panait
2026-06-08 13:59 ` Rafael J. Wysocki
2026-06-06 21:04 ` [PATCH 3/3] thermal: sysfs: Replace sscanf() with kstrtoul() Ovidiu Panait
2026-06-07 2:52 ` [PATCH 1/3] thermal: testing: Avoid NULL pointer dereference on missing arg Guru Das Srinagesh
2026-06-07 11:23 ` David Laight
2026-06-07 19:55 ` Guru Das Srinagesh [this message]
2026-06-07 20:47 ` David Laight
2026-06-08 13:49 ` Rafael J. Wysocki
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=aiXMoaYaRlTsMwqd@gurudas.dev \
--to=linux@gurudas.dev \
--cc=daniel.lezcano@kernel.org \
--cc=david.laight.linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=ovidiu.panait.oss@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