iio: accel: mma9551: Check gpiod_to_irq return value
authorRoberta Dobrescu <roberta.dobrescu@gmail.com>
Mon, 2 Mar 2015 10:39:12 +0000 (12:39 +0200)
committerJonathan Cameron <jic23@kernel.org>
Mon, 9 Mar 2015 13:27:49 +0000 (13:27 +0000)
The return value of gpiod_to_irq should be checked before giving
it to devm_request_threaded_irq in order to not pass an error
code in case it fails.

Signed-off-by: Roberta Dobrescu <roberta.dobrescu@gmail.com>
Reviewed-by: Vlad Dogaru <vlad.dogaru@intel.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/accel/mma9551.c

index 1277f407cd12ef037bbc10cd0d8d14438f94b898..7db7cc0bf362fceb3b97c770cc0ef0552dd4c4d3 100644 (file)
@@ -425,7 +425,11 @@ static int mma9551_gpio_probe(struct iio_dev *indio_dev)
                        return PTR_ERR(gpio);
                }
 
-               data->irqs[i] = gpiod_to_irq(gpio);
+               ret = gpiod_to_irq(gpio);
+               if (ret < 0)
+                       return ret;
+
+               data->irqs[i] = ret;
                ret = devm_request_threaded_irq(dev, data->irqs[i],
                                NULL, mma9551_event_handler,
                                IRQF_TRIGGER_RISING | IRQF_ONESHOT,