iio: pressure: bmp280: Fix NULL pointer exception
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.
--- drivers/iio/pressure/bmp280-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/pressure/bmp280-core.c +1 -1
@@ -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
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")Signed-off-by Phil Elwell <[email protected]>
Looks like a logic mistake.
Yours,
Linus Walleij
Jonathan Cameron
maintainerQuoted 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")Signed-off-by Phil Elwell <[email protected]>Looks like a logic mistake.
Reviewed-by Linus Walleij <[email protected]>
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