Commit 85dfb43b authored by Phil Elwell's avatar Phil Elwell Committed by Jonathan Cameron

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: aae95394 ("iio: pressure: bmp280: add support for BMP085 EOC interrupt")
Signed-off-by: default avatarPhil Elwell <phil@raspberrypi.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20230811155829.51208-1-phil@raspberrypi.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 9a85653e
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment