Skip to contentSkip to conversation

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

PATCH Applied Fabio Estevam 2 participants 2 messages Jun 22, 2017 – Aug 14, 2017

Subsystems (3)
lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH v2 1/1 input: touchscreen: mxs-lradc: Do a NULL check on iores

From: Fabio Estevam <[email protected]>

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

---
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(+)
drivers/input/touchscreen/mxs-lradc-ts.c +2 -0
index 58c016c..71bf493 100644
@@ -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);
Signature · 1 line
2.7.4
maintainer Applied
#1 lore raw
Quoted 6 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

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

Applied, thank you.

Quoted 23 lines

---
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(+)
drivers/input/touchscreen/mxs-lradc-ts.c +2 -0
index 58c016c..71bf493 100644
@@ -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);
Signature · 1 line
2.7.4
Signature · 1 line
Dmitry