iio: adc: fix a potential NULL pointer dereference
authorKangjie Lu <kjlu@umn.edu>
Sat, 9 Mar 2019 04:53:55 +0000 (22:53 -0600)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Thu, 4 Apr 2019 19:19:53 +0000 (20:19 +0100)
devm_iio_trigger_alloc may fail and return NULL. The fix returns
ENOMEM when it fails.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/mxs-lradc-adc.c

index c627513d9f0f21eb39018d783e05c82b3fca8417..5384472b6c4d0c8ba9c4f4482f600fbbf29a8599 100644 (file)
@@ -465,6 +465,8 @@ static int mxs_lradc_adc_trigger_init(struct iio_dev *iio)
 
        trig = devm_iio_trigger_alloc(&iio->dev, "%s-dev%i", iio->name,
                                      iio->id);
+       if (!trig)
+               return -ENOMEM;
 
        trig->dev.parent = adc->dev;
        iio_trigger_set_drvdata(trig, iio);