Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1540121

[V2] mtd: devices: docg3:- Handle return value of devm_ioremap.

From Arvind Yadav <arvind.yadav.cs@gmail.com>
Newsgroups linux.kernel
Subject [V2] mtd: devices: docg3:- Handle return value of devm_ioremap.
Date 2016-12-12 04:10 +0100
Message-ID <sNpa1-7mg-9@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[V2] mtd: devices: docg3:- Handle return value of devm_ioremap. Arvind Yadav <arvind.yadav.cs@gmail.com> - 2016-12-12 04:10 +0100
  Re: [V2] mtd: devices: docg3:- Handle return value of devm_ioremap. Marek Vasut <marek.vasut@gmail.com> - 2016-12-12 05:20 +0100
  Re: [V2] mtd: devices: docg3:- Handle return value of devm_ioremap. Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-12-12 09:50 +0100
    Re: [V2] mtd: devices: docg3:- Handle return value of devm_ioremap. arvind Yadav <arvind.yadav.cs@gmail.com> - 2016-12-12 17:10 +0100
      Re: [V2] mtd: devices: docg3:- Handle return value of devm_ioremap. Robert Jarzmik <robert.jarzmik@free.fr> - 2016-12-12 17:40 +0100
        Re: [V2] mtd: devices: docg3:- Handle return value of devm_ioremap. Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-12-12 18:10 +0100
      Re: [V2] mtd: devices: docg3:- Handle return value of devm_ioremap. Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-12-12 18:10 +0100
        Re: [V2] mtd: devices: docg3:- Handle return value of devm_ioremap. arvind Yadav <arvind.yadav.cs@gmail.com> - 2016-12-12 19:20 +0100

csiph-web