From: Christian Lamparter <chunkeey@gmail.com>
To: Dan Carpenter <error27@gmail.com>
Cc: linux-wireless@vger.kernel.org
Subject: Re: [PATCH 3/3] wifi: carl9170: NUL terminate string in debugfs
Date: Thu, 1 Oct 2026 19:58:13 +0200 [thread overview]
Message-ID: <e550f231-87cd-4220-a17e-d0288516ef9e@gmail.com> (raw)
In-Reply-To: <674270ab4aeefa1982362c0ea4132427e14f15eb.1790839793.git.error27@gmail.com>
On 10/1/26 9:37 AM, Dan Carpenter wrote:
> The "buf" buffer comes from the user. We use it to store a number or
> two so it doesn't need to be large. It gets passed to sscanf() in the
> write functions such as carl9170_debugfs_erp_write(). Ensure that
> buffer is NUL terminated.
>
> This is debugfs so it's root only.
Sure.
>
> Fixes: 00c4da27a421 ("carl9170: firmware parser and debugfs code")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Christian Lamparter <chunkeey@gmail.com>
> ---
> drivers/net/wireless/ath/carl9170/debug.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/carl9170/debug.c b/drivers/net/wireless/ath/carl9170/debug.c
> index 0498df2a2160..bc6c8e0b1d16 100644
> --- a/drivers/net/wireless/ath/carl9170/debug.c
> +++ b/drivers/net/wireless/ath/carl9170/debug.c
> @@ -119,7 +119,7 @@ static ssize_t carl9170_debugfs_write(struct file *file,
> if (!count)
> return 0;
>
> - if (count > PAGE_SIZE)
> + if (count >= PAGE_SIZE)
heh. It's unnecessary to change this for the max. two numbers we get.
But I'm curious if this is a change that an AI tool added?
But yeah, it's still fine.
> return -E2BIG;
>
> ar = file->private_data;
> @@ -131,7 +131,7 @@ static ssize_t carl9170_debugfs_write(struct file *file,
> if (!dfops->write)
> return -ENOSYS;
>
> - buf = vmalloc(count);
> + buf = vmalloc(count + 1);
I think there's also a vzalloc...
> if (!buf)
> return -ENOMEM;
>
> @@ -139,6 +139,7 @@ static ssize_t carl9170_debugfs_write(struct file *file,
> err = -EFAULT;
> goto out_free;
> }
> + buf[count] = '\0';
which would eliminate that. But yeah, this is fine as well.
>
> if (mutex_trylock(&ar->mutex) == 0) {
> err = -EAGAIN;
next prev parent reply other threads:[~2026-10-01 17:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 7:37 [PATCH 0/3] wifi: NULL terminate some user strings Dan Carpenter
2026-10-01 7:37 ` [PATCH 1/3] wifi: b43: don't pass unterminated string to sscanf() Dan Carpenter
2026-10-01 7:37 ` [PATCH 2/3] wifi: b43legacy: debugfs: NUL terminate string in debugfs Dan Carpenter
2026-10-01 7:37 ` [PATCH 3/3] wifi: carl9170: " Dan Carpenter
2026-10-01 17:58 ` Christian Lamparter [this message]
2026-10-01 18:31 ` Dan Carpenter
2026-10-03 22:49 ` Jeff Johnson
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=e550f231-87cd-4220-a17e-d0288516ef9e@gmail.com \
--to=chunkeey@gmail.com \
--cc=error27@gmail.com \
--cc=linux-wireless@vger.kernel.org \
/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