Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: pressure: bmp280: Fix NULL pointer exception
@ 2023-08-11 15:58 Phil Elwell
  2023-08-11 17:38 ` Linus Walleij
  0 siblings, 1 reply; 3+ messages in thread
From: Phil Elwell @ 2023-08-11 15:58 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Phil Elwell, Linus Walleij,
	linux-iio

The bmp085 EOC IRQ support is optional, but the driver's common probe
function queries the IRQ properties whether or not it exists, which
can trigger a NULL pointer exception. Avoid any exception by making
the query conditional on the possession of a valid IRQ.

Fixes: aae953949651 ("iio: pressure: bmp280: add support for BMP085 EOC interrupt")
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
---
 drivers/iio/pressure/bmp280-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
index 6089f3f9d8f4b..a2ef1373a274e 100644
--- a/drivers/iio/pressure/bmp280-core.c
+++ b/drivers/iio/pressure/bmp280-core.c
@@ -2179,7 +2179,7 @@ int bmp280_common_probe(struct device *dev,
 	 * however as it happens, the BMP085 shares the chip ID of BMP180
 	 * so we look for an IRQ if we have that.
 	 */
-	if (irq > 0 || (chip_id  == BMP180_CHIP_ID)) {
+	if (irq > 0 && (chip_id  == BMP180_CHIP_ID)) {
 		ret = bmp085_fetch_eoc_irq(dev, name, irq, data);
 		if (ret)
 			return ret;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: pressure: bmp280: Fix NULL pointer exception
  2023-08-11 15:58 [PATCH] iio: pressure: bmp280: Fix NULL pointer exception Phil Elwell
@ 2023-08-11 17:38 ` Linus Walleij
  2023-08-28 11:37   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2023-08-11 17:38 UTC (permalink / raw)
  To: Phil Elwell; +Cc: Jonathan Cameron, Lars-Peter Clausen, linux-iio

On Fri, Aug 11, 2023 at 5:58 PM Phil Elwell <phil@raspberrypi.com> wrote:

> The bmp085 EOC IRQ support is optional, but the driver's common probe
> function queries the IRQ properties whether or not it exists, which
> can trigger a NULL pointer exception. Avoid any exception by making
> the query conditional on the possession of a valid IRQ.
>
> Fixes: aae953949651 ("iio: pressure: bmp280: add support for BMP085 EOC interrupt")
> Signed-off-by: Phil Elwell <phil@raspberrypi.com>

Looks like a logic mistake.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: pressure: bmp280: Fix NULL pointer exception
  2023-08-11 17:38 ` Linus Walleij
@ 2023-08-28 11:37   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2023-08-28 11:37 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Phil Elwell, Lars-Peter Clausen, linux-iio

On Fri, 11 Aug 2023 19:38:09 +0200
Linus Walleij <linus.walleij@linaro.org> wrote:

> On Fri, Aug 11, 2023 at 5:58 PM Phil Elwell <phil@raspberrypi.com> wrote:
> 
> > The bmp085 EOC IRQ support is optional, but the driver's common probe
> > function queries the IRQ properties whether or not it exists, which
> > can trigger a NULL pointer exception. Avoid any exception by making
> > the query conditional on the possession of a valid IRQ.
> >
> > Fixes: aae953949651 ("iio: pressure: bmp280: add support for BMP085 EOC interrupt")
> > Signed-off-by: Phil Elwell <phil@raspberrypi.com>  
> 
> Looks like a logic mistake.
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
I've applied this locally but given my tree is currently ahead of its
parent ready for the merge to happen, I won't push this out until
char-misc-next has been merged upstream.

Thanks,

Jonathan

> 
> Yours,
> Linus Walleij


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-28 11:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-11 15:58 [PATCH] iio: pressure: bmp280: Fix NULL pointer exception Phil Elwell
2023-08-11 17:38 ` Linus Walleij
2023-08-28 11:37   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox