From: Guru Das Srinagesh <linux@gurudas.dev>
To: Ovidiu Panait <ovidiu.panait.oss@gmail.com>
Cc: 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: Sat, 6 Jun 2026 19:52:49 -0700 [thread overview]
Message-ID: <aiTdAQ6uCuFenv7N@shakti> (raw)
In-Reply-To: <20260606210420.2311145-1-ovidiu.panait.oss@gmail.com>
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.
next prev parent reply other threads:[~2026-06-07 3:00 UTC|newest]
Thread overview: 5+ 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-06 21:04 ` [PATCH 3/3] thermal: sysfs: Replace sscanf() with kstrtoul() Ovidiu Panait
2026-06-07 2:52 ` Guru Das Srinagesh [this message]
2026-06-07 11:23 ` [PATCH 1/3] thermal: testing: Avoid NULL pointer dereference on missing arg David Laight
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=aiTdAQ6uCuFenv7N@shakti \
--to=linux@gurudas.dev \
--cc=daniel.lezcano@kernel.org \
--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