Message ID | 20230811155829.51208-1-phil@raspberrypi.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | iio: pressure: bmp280: Fix NULL pointer exception | expand |
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
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
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;
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(-)