All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Marco Chen <marcochen.dev@gmail.com>
Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
	pmeerw@pmeerw.net, matt@ranostay.sg, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org, skhan@linuxfoundation.org,
	linux-kernel-mentees@lists.linux.dev
Subject: Re: [PATCH v1] iio: health: max30102: fix NULL dereference in interrupt handler
Date: Wed, 5 Aug 2026 00:25:48 +0100	[thread overview]
Message-ID: <20260805002548.01ff7177@jic23-huawei> (raw)
In-Reply-To: <anADiCtmoVbT0o2F@xiaolong>

On Mon, 3 Aug 2026 00:13:33 -0400
Marco Chen <marcochen.dev@gmail.com> wrote:

> On Sun, Aug 02, 2026 at 03:26:09AM +0100, Jonathan Cameron wrote:
> > > +	if (!indio_dev->active_scan_mask) {  
> > 
> > That is racy as this could be going on in parallel with the buffer being disabled
> > so we check here but it's gone before it is accessed.  
> 
> I understand what you mean. I will remove this active_scan_mask check.
> 
> > Which leads me to suggest alternative fix - check INT_STATUS and if nothing
> > set it isn't our interrupt.  That doesn't get into the potential buffer
> > enabled / disabled races but should close your condition I think
> > - looks like it is read in the fifo part below. You may need to refactor a
> > little to not read it twice.  
> 
> This makes a lot of sense. For the v2 patch, I will plan to read
> INT_STATUS once at the top of the handler and pass that value into
> max30102_fifo_count() so it is not read twice. Consequently I will
> remove the INT_STATUS read from max30102_fifo_count(), too.
> 
> For checking INT_STATUS to see if it isn't our interrupt, instead of
> checking if nothing is set, I was thinking to check the
> MAX30102_REG_INT_STATUS_FIFO_RDY bit specifically because that is the 
> only interrupt enabled in max30102_chip_init().

Agreed. That is a better solution than mine :)

> 
> This will close the reproducer I was hitting earlier as you said. Since
> we only ever reach bitmap_weight() when FIFO_RDY is set, the NULL dereference
> is avoided. I think there is a theoretical window if the buffer is disabled
> between the FIFO_RDY check and bitmap_weight() call, but as you said,
> closing this would need the buffered mode claim. I plan to leave that
> out of this fix.


      reply	other threads:[~2026-08-04 23:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31 18:41 [PATCH v1] iio: health: max30102: fix NULL dereference in interrupt handler Marco Chen
2026-08-01 15:18 ` David Lechner
2026-08-02  2:10   ` Jonathan Cameron
2026-08-02 15:21     ` David Lechner
2026-08-02 17:41       ` Jonathan Cameron
2026-08-02  2:26 ` Jonathan Cameron
2026-08-03  4:13   ` Marco Chen
2026-08-04 23:25     ` 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=20260805002548.01ff7177@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel-mentees@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcochen.dev@gmail.com \
    --cc=matt@ranostay.sg \
    --cc=nuno.sa@analog.com \
    --cc=pmeerw@pmeerw.net \
    --cc=skhan@linuxfoundation.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 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.