From: Jonathan Cameron <jic23@kernel.org>
To: Arnav Kapoor <kapoorarnav43@gmail.com>
Cc: Zhu Jun <zhujun2@cmss.chinamobile.com>,
dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tools: iio: Keep the buffer index separate from the acquired fd
Date: Sat, 21 Nov 2026 21:19:02 +0000 [thread overview]
Message-ID: <20261121211902.13a9f3ed@jic23-hlaptop> (raw)
In-Reply-To: <20261120210317.184756-2-kapoorarnav43@gmail.com>
On Sat, 21 Nov 2026 02:33:17 +0530
Arnav Kapoor <kapoorarnav43@gmail.com> wrote:
> On Fri, Nov 20, 2026 at 02:19:03PM +0800, Zhu Jun wrote:
> > IIO_BUFFER_GET_FD_IOCTL takes the buffer index as input and replaces
> > it with a file descriptor on success. On failure, cleanup can mistake
> > the unchanged index for an open fd and close a different file. Only
> > assign the returned descriptor to buf_fd after successful acquisition.
>
> Checked against iio_device_buffer_getfd(): on every error path it
> returns before copy_to_user(), so the argument keeps the index, and the
> error: label then closes it because buf_fd >= 0. With the default
> buffer index 0 that closes stdin, with -b 1 stdout. The patch fixes
> that, buffer_idx is already rejected when negative, and it applies to
> iio testing, builds without warnings and is checkpatch --strict clean.
>
> Reviewed-by: Arnav Kapoor <kapoorarnav43@gmail.com>
Applied to the testing branch of iio.git. That means it is queued up
for the next merge window.
Thanks,
Jonathan
prev parent reply other threads:[~2026-11-21 21:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 6:19 Zhu Jun
2026-11-20 21:03 ` Arnav Kapoor
2026-11-21 21:19 ` Jonathan Cameron [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=20261121211902.13a9f3ed@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=kapoorarnav43@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=zhujun2@cmss.chinamobile.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
all inboxes | Powered by JetHome®