iio: adc: rockchip_saradc: add NULL check on of_match_device() return value
Subsystems (2)
PATCH 1/1 iio: adc: rockchip_saradc: add NULL check on of_match_device() return value
Check return value from call to of_match_device()
in order to prevent a NULL pointer dereference.
In case of NULL print error message and return -ENODEV
Signed-off-by Gustavo A. R. Silva <[email protected]>
--- drivers/iio/adc/rockchip_saradc.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/iio/adc/rockchip_saradc.c +5 -0
@@ -224,6 +224,11 @@ static int rockchip_saradc_probe(struct platform_device *pdev) info =iio_priv (indio_dev); match =of_match_device (rockchip_saradc_match, &pdev->dev); +if (!match) { +dev_err (&pdev->dev,"failed to match device\n" ); +return -ENODEV ; + } + info->data = match->data; mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 );
Signature · 1 line
2.5.0
Quoted 6 lines · On Fri, 7 Jul 2017 01:51:31 -0500 "Gustavo A. R. Silva"…
Check return value from call to
of_match_device()
in order to prevent a NULL pointer dereference.In case of NULL print error message and return
-ENODEVSigned-off-by Gustavo A. R. Silva <[email protected]>
Applied.
Thanks,
Jonathan
Quoted 20 lines
--- drivers/iio/adc/rockchip_saradc.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/iio/adc/rockchip_saradc.c +5
-0@@ -224,6 +224,11 @@ static int rockchip_saradc_probe(struct platform_device *pdev) info =iio_priv (indio_dev); match =of_match_device (rockchip_saradc_match, &pdev->dev); +if (!match) { +dev_err (&pdev->dev,"failed to match device\n" ); +return -ENODEV ; + } + info->data = match->data; mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 );
Quoted 11 lines · Jonathan Cameron
Quoted 6 lines · On Fri, 7 Jul 2017 01:51:31 -0500 "Gustavo A. R. Silva"…
Check return value from call to
of_match_device()
in order to prevent a NULL pointer dereference.In case of NULL print error message and return
-ENODEVSigned-off-by Gustavo A. R. Silva <[email protected]>Applied.
Thank you, Jonathan.
Signature · 1 line
Gustavo A. R. Silva