public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [V2] mtd: devices: docg3:- Handle return value of devm_ioremap.
@ 2016-12-12  3:00 Arvind Yadav
  2016-12-12  4:10 ` Marek Vasut
  2016-12-12  8:42 ` Boris Brezillon
  0 siblings, 2 replies; 8+ messages in thread
From: Arvind Yadav @ 2016-12-12  3:00 UTC (permalink / raw)
  To: robert.jarzmik, dwmw2, computersforpeace, boris.brezillon,
	marek.vasut, richard, cyrille.pitchen
  Cc: linux-mtd, linux-kernel

Here, If devm_ioremap will fail. It will return NULL.
Kernel can run into a NULL-pointer dereference.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/mtd/devices/docg3.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c
index b833e6c..ffe3db0 100644
--- a/drivers/mtd/devices/docg3.c
+++ b/drivers/mtd/devices/docg3.c
@@ -2083,9 +2083,14 @@ static int __init docg3_probe(struct platform_device *pdev)
 		dev_err(dev, "No I/O memory resource defined\n");
 		return ret;
 	}
-	base = devm_ioremap(dev, ress->start, DOC_IOSPACE_SIZE);
 
 	ret = -ENOMEM;
+	base = devm_ioremap(dev, ress->start, DOC_IOSPACE_SIZE);
+	if (!base) {
+		dev_err(dev, "failed to map I/O memory\n");
+		return ret;
+	}
+
 	cascade = devm_kzalloc(dev, sizeof(*cascade) * DOC_MAX_NBFLOORS,
 			       GFP_KERNEL);
 	if (!cascade)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-12-12 18:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-12  3:00 [V2] mtd: devices: docg3:- Handle return value of devm_ioremap Arvind Yadav
2016-12-12  4:10 ` Marek Vasut
2016-12-12  8:42 ` Boris Brezillon
2016-12-12 16:03   ` arvind Yadav
2016-12-12 16:32     ` Robert Jarzmik
2016-12-12 17:00       ` Boris Brezillon
2016-12-12 17:04     ` Boris Brezillon
2016-12-12 18:15       ` arvind Yadav

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox