Skip to contentSkip to conversation

iio: pressure: bmp280: Fix NULL pointer exception

PATCH In review Phil Elwell 3 participants 3 messages Aug 11, 2023 – Aug 28, 2023 IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: pressure: bmp280: Fix NULL pointer exception

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")
---
 drivers/iio/pressure/bmp280-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/pressure/bmp280-core.c +1 -1
index 6089f3f9d8f4b..a2ef1373a274e 100644
@@ -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;
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Phil Elwell

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")

Looks like a logic mistake.

Yours,
Linus Walleij

maintainer
#2 lore raw
Quoted 7 lines · On Fri, 11 Aug 2023 19:38:09 +0200 Linus Walleij <[email protected]>…
Quoted 5 lines · Phil Elwell

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.

Quoted 5 lines
Quoted 2 lines
Fixes aae953949651 ("iio: pressure: bmp280: add support for BMP085 EOC interrupt")

Looks like a logic mistake.

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

Quoted 3 lines

Yours,
Linus Walleij