Commit 13814627 authored by Kangjie Lu's avatar Kangjie Lu Committed by Jonathan Cameron

iio: adc: fix a potential NULL pointer dereference

devm_iio_trigger_alloc may fail and return NULL. The fix returns
ENOMEM when it fails.
Signed-off-by: default avatarKangjie Lu <kjlu@umn.edu>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent d43102f5
...@@ -465,6 +465,8 @@ static int mxs_lradc_adc_trigger_init(struct iio_dev *iio) ...@@ -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, trig = devm_iio_trigger_alloc(&iio->dev, "%s-dev%i", iio->name,
iio->id); iio->id);
if (!trig)
return -ENOMEM;
trig->dev.parent = adc->dev; trig->dev.parent = adc->dev;
iio_trigger_set_drvdata(trig, iio); iio_trigger_set_drvdata(trig, iio);
......
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