All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Maxwell Doose" <m32285159@gmail.com>
To: "Felix Gu" <ustc.gu@gmail.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Arnaud Pouliquen" <arnaud.pouliquen@st.com>,
	"Mark Brown" <broonie@kernel.org>
Cc: <linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	"sashiko" <sashiko-bot@kernel.org>
Subject: Re: [PATCH v2] iio: buffer: hw-consumer: fix use-after-free in error path
Date: Thu, 30 Apr 2026 20:27:27 -0500	[thread overview]
Message-ID: <DI6Y78RY6DRL.HBDGRFK0BCFO@gmail.com> (raw)
In-Reply-To: <20260430-iio-buf-v2-1-84c2231dea5e@gmail.com>

On Thu Apr 30, 2026 at 8:29 AM CDT, Felix Gu wrote:
> In the err_put_buffers cleanup path of iio_hw_consumer_alloc(), the code
> was using list_for_each_entry() to iterate through buffers while calling
> iio_buffer_put() which can free the current buffer if refcount drops to 0=
.
> The list_for_each_entry() loop macro then evaluates buf->head.next to
> continue iteration, accessing the freed buffer.
>
> Fix this by using list_for_each_entry_safe().
>
> Fixes: 48b66f8f936f ("iio: Add hardware consumer buffer support")
> Reported-by: sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/patchset/20260427-iio_buf-v1-1-2bbdac844647@gmail.com
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
> ---
> Changes in v2:
> - Fix Andy's comment.
> - Add Reported-by tag.
> - Link to v1: https://lore.kernel.org/r/20260428-iio-buf-v1-1-dcc63ff7b80@gmail.com
> ---
>  drivers/iio/buffer/industrialio-hw-consumer.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>

Looks fine to me.

Reviewed-by: Maxwell Doose <m32285159@gmail.com>

best regards,
maxwell



> Best regards,
> --=
> Felix Gu <ustc.gu@gmail.com>


  reply	other threads:[~2026-05-01  1:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-30 13:29 [PATCH v2] iio: buffer: hw-consumer: fix use-after-free in error path Felix Gu
2026-05-01  1:27 ` Maxwell Doose [this message]
2026-05-05 12:39   ` Jonathan Cameron
2026-05-01  8:59 ` Nuno Sá
2026-05-01 14:19 ` Joshua Crofts
2026-05-01 15:47   ` Maxwell Doose
2026-05-01 19:40     ` Joshua Crofts
2026-05-02  2:38       ` Maxwell Doose
2026-05-04  7:03 ` 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=DI6Y78RY6DRL.HBDGRFK0BCFO@gmail.com \
    --to=m32285159@gmail.com \
    --cc=andy@kernel.org \
    --cc=arnaud.pouliquen@st.com \
    --cc=broonie@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=sashiko-bot@kernel.org \
    --cc=ustc.gu@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.