From: Dan Carpenter <error27@gmail.com>
To: Maxwell Doose <m32285159@gmail.com>
Cc: "Nuno Sá" <nuno.sa@analog.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] iio: core: fix uninitialized data in debugfs
Date: Mon, 25 May 2026 19:12:57 +0300 [thread overview]
Message-ID: <ahR1CUxzMkYDwVvO@stanley.mountain> (raw)
In-Reply-To: <CAKqfh0H0Z0xr4bAjctr9h95QTuEUTF1eCgBsRZVHn_KrkZZX3g@mail.gmail.com>
On Mon, May 25, 2026 at 08:17:28AM -0500, Maxwell Doose wrote:
> Hi Dan,
>
> On Mon, May 25, 2026 at 2:19 AM Dan Carpenter <error27@gmail.com> wrote:
> >
> > If *ppos is non-zero then simple_write_to_buffer() will not initialize
> > the start of buf[]. Non zero values for *ppos aren't going to work
> > anyway. Test for them at the start of the function and return -EINVAL.
> >
> > Fixes: 6d5dd486c715 ("iio: core: make use of simple_write_to_buffer()")
> > Signed-off-by: Dan Carpenter <error27@gmail.com>
> > ---
> > The original copy_from_user() code was better:
> > https://staticthinking.wordpress.com/2026/05/23/simple_write_to_buffer-is-complicated/
> > ---
> > drivers/iio/industrialio-core.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
>
> Codewise looks good but often times people will prefer
>
> if (*ppos || count >= sizeof(buf))
>
> over
>
> if (*ppos != 0 || count >= sizeof(buf))
In this context, I feel like either is acceptable since zero
represents the number zero. I have a blog about that which I have
been trying to promote. #SEO
https://staticthinking.wordpress.com/2024/02/20/when-to-use-0/
>
> Regardless,
>
> Reviewed-by: Maxwell Doose <m32285159@gmail.com>
>
Thanks. And you're other comments with regards to -EINVAL and
-ENOSPC are obviously correct.
regards,
dan carpenter
next prev parent reply other threads:[~2026-05-25 16:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-25 7:16 [PATCH] iio: core: fix uninitialized data in debugfs Dan Carpenter
2026-05-25 13:17 ` Maxwell Doose
2026-05-25 16:12 ` Dan Carpenter [this message]
2026-05-25 20:08 ` Maxwell Doose
2026-05-26 18:21 ` Jonathan Cameron
2026-06-04 7:31 ` Andy Shevchenko
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=ahR1CUxzMkYDwVvO@stanley.mountain \
--to=error27@gmail.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m32285159@gmail.com \
--cc=nuno.sa@analog.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