diff mbox series

iio: adc: fix a potential NULL pointer dereference

Message ID 20190309045356.8892-1-kjlu@umn.edu (mailing list archive)
State New, archived
Headers show
Series iio: adc: fix a potential NULL pointer dereference | expand

Commit Message

Kangjie Lu March 9, 2019, 4:53 a.m. UTC
devm_iio_trigger_alloc may fail and return NULL. The fix returns
ENOMEM when it fails.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 drivers/iio/adc/mxs-lradc-adc.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Jonathan Cameron March 9, 2019, 6:32 p.m. UTC | #1
On Fri,  8 Mar 2019 22:53:55 -0600
Kangjie Lu <kjlu@umn.edu> wrote:

> devm_iio_trigger_alloc may fail and return NULL. The fix returns
> ENOMEM when it fails.
> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Seems obviously correct to me.  As it's been there a 'while'
I'm not going to rush it in however. This can wait for the next
merge window.

Applied to the togreg branch of iio.git and pushed out as
testing for the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/mxs-lradc-adc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/iio/adc/mxs-lradc-adc.c b/drivers/iio/adc/mxs-lradc-adc.c
> index c627513d9f0f..5384472b6c4d 100644
> --- a/drivers/iio/adc/mxs-lradc-adc.c
> +++ b/drivers/iio/adc/mxs-lradc-adc.c
> @@ -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);
diff mbox series

Patch

diff --git a/drivers/iio/adc/mxs-lradc-adc.c b/drivers/iio/adc/mxs-lradc-adc.c
index c627513d9f0f..5384472b6c4d 100644
--- a/drivers/iio/adc/mxs-lradc-adc.c
+++ b/drivers/iio/adc/mxs-lradc-adc.c
@@ -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);