mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: "Nuno Sá" <nuno.sa@analog.com>
Cc: Joshua Crofts <joshua.crofts1@gmail.com>,
	Dingisoul <dingiso.kernel@gmail.com>,
	Linus Walleij <linusw@kernel.org>,
	David Lechner <dlechner@baylibre.com>,
	Andy Shevchenko <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH v2] iio: gyro: mpu3050: add missing trigger cleanup on remove
Date: Sat, 17 Oct 2026 01:51:22 +0100	[thread overview]
Message-ID: <20261017015122.7a902b28@jic23-hlaptop> (raw)
In-Reply-To: <atHinTYMtjsY45wY@nsa>

On Fri, 16 Oct 2026 09:39:51 +0100
Nuno Sá <nuno.sa@analog.com> wrote:

> On Thu, Oct 15, 2026 at 10:18:18PM +0200, Joshua Crofts wrote:
> > On Thu, 15 Oct 2026 21:58:35 +0200
> > Joshua Crofts <joshua.crofts1@gmail.com> wrote:
> >   
> > > The mpu3050_trigger_probe() function registers a trigger but
> > > mpu3050_common_remove() and error paths in mpu3050_common_probe() forget
> > > to clean it up, causing a use-after-free bug.
> > > 
> > > Add the missing iio_trigger_unregister() function. Additionally, change
> > > the mpu3050_trigger_probe() function to assign trig only after it is
> > > registered successfully to prevent a null pointer dereference using a
> > > local struct iio_trigger.
> > > 
> > > Reported-by: Dingisoul <dingiso.kernel@gmail.com>
> > > Closes: https://lore.kernel.org/all/20261010203601.1686148-1-dingiso.kernel@gmail.com/
> > > Fixes: 3904b28efb2c ("iio: gyro: Add driver for the MPU-3050 gyroscope")
> > > Cc: stable@vger.kernel.org
> > > Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
> > > ---  
> > 
> > Dingisoul, any chance you can test this?
> > 
> > Q to others: better to leave the driver running in this weird
> > polling mode as it is now or return on trigger register failure
> > as Nuno suggests?  
> 
> Don't think it makes sense to continue if the idea is to have trigger
> but something failed when dealing with it. At the very least we should
> then drop the memory we allocated for it.

Fully agree. If there is an irq and trigger registration fails, fail
the probe.  Not doing that just leaves us with more corner cases
to bite us in future (such as tidying up the otherwise devm managed
trigger).  Note the mix of devm and non devm in here isn't something
we'd do today but may not be worth the effort of cleaning up.

Jonathan

> 
> - Nuno Sá
> > 
> > Thanks.
> > 
> > -- 
> > Kind regards,
> > Joshua Crofts  


      reply	other threads:[~2026-10-17  0:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15 19:58 Joshua Crofts
2026-10-15 20:18 ` Joshua Crofts
2026-10-15 20:35   ` Dingisoul
2026-10-15 20:41     ` Joshua Crofts
2026-10-16  8:39   ` Nuno Sá
2026-10-17  0:51     ` 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=20261017015122.7a902b28@jic23-hlaptop \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=dingiso.kernel@gmail.com \
    --cc=dlechner@baylibre.com \
    --cc=joshua.crofts1@gmail.com \
    --cc=linusw@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=stable@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

all inboxes | Powered by JetHome®