summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Elwell <phil@raspberrypi.com>2023-08-11 16:58:29 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-10-25 11:13:30 +0200
commita8ce1f8aeac994654fc2e7ec9cfbae15aee6b72a (patch)
tree6c62555205fa928b063f03a5a524b95199434b5f
parent9d350bd2543a9e9f6861b3ed81642d21e42de158 (diff)
iio: pressure: bmp280: Fix NULL pointer exception
commit 85dfb43bf69281adb1f345dfd9a39faf2e5a718d upstream. 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> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20230811155829.51208-1-phil@raspberrypi.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/iio/pressure/bmp280-core.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
index ae415b4e381a..0714da47a2f9 100644
--- a/drivers/iio/pressure/bmp280-core.c
+++ b/drivers/iio/pressure/bmp280-core.c
@@ -1050,7 +1050,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)
goto out_disable_vdda;