diff mbox

[v2] input: touchscreen: mxs-lradc: Do a NULL check on iores

Message ID 1498099872-16959-1-git-send-email-festevam@gmail.com (mailing list archive)
State Accepted
Headers show

Commit Message

Fabio Estevam June 22, 2017, 2:51 a.m. UTC
From: Fabio Estevam <fabio.estevam@nxp.com>

platform_get_resource() may fail, so we should better do a NULL check
and return error on failure.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
Changes since v1:
- Instead of using devm_ioremap_resource, do a NULL check on iores

 drivers/input/touchscreen/mxs-lradc-ts.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Dmitry Torokhov Aug. 14, 2017, 5:26 p.m. UTC | #1
On Wed, Jun 21, 2017 at 11:51:12PM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@nxp.com>
> 
> platform_get_resource() may fail, so we should better do a NULL check
> and return error on failure.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>

Applied, thank you.

> ---
> Changes since v1:
> - Instead of using devm_ioremap_resource, do a NULL check on iores
> 
>  drivers/input/touchscreen/mxs-lradc-ts.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/input/touchscreen/mxs-lradc-ts.c b/drivers/input/touchscreen/mxs-lradc-ts.c
> index 58c016c..71bf493 100644
> --- a/drivers/input/touchscreen/mxs-lradc-ts.c
> +++ b/drivers/input/touchscreen/mxs-lradc-ts.c
> @@ -630,6 +630,8 @@ static int mxs_lradc_ts_probe(struct platform_device *pdev)
>  	spin_lock_init(&ts->lock);
>  
>  	iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	if (!iores)
> +		return -EINVAL;
>  	ts->base = devm_ioremap(dev, iores->start, resource_size(iores));
>  	if (IS_ERR(ts->base))
>  		return PTR_ERR(ts->base);
> -- 
> 2.7.4
>
diff mbox

Patch

diff --git a/drivers/input/touchscreen/mxs-lradc-ts.c b/drivers/input/touchscreen/mxs-lradc-ts.c
index 58c016c..71bf493 100644
--- a/drivers/input/touchscreen/mxs-lradc-ts.c
+++ b/drivers/input/touchscreen/mxs-lradc-ts.c
@@ -630,6 +630,8 @@  static int mxs_lradc_ts_probe(struct platform_device *pdev)
 	spin_lock_init(&ts->lock);
 
 	iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!iores)
+		return -EINVAL;
 	ts->base = devm_ioremap(dev, iores->start, resource_size(iores));
 	if (IS_ERR(ts->base))
 		return PTR_ERR(ts->base);