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


Groups > linux.kernel > #1572349 > unrolled thread

[PATCH] parisc: ccio-dma: Handle return NULL error from ioremap_nocache

Started byArvind Yadav <arvind.yadav.cs@gmail.com>
First post2017-02-02 14:30 +0100
Last post2017-02-02 14:30 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] parisc: ccio-dma: Handle return NULL error from ioremap_nocache Arvind Yadav <arvind.yadav.cs@gmail.com> - 2017-02-02 14:30 +0100

#1572349 — [PATCH] parisc: ccio-dma: Handle return NULL error from ioremap_nocache

FromArvind Yadav <arvind.yadav.cs@gmail.com>
Date2017-02-02 14:30 +0100
Subject[PATCH] parisc: ccio-dma: Handle return NULL error from ioremap_nocache
Message-ID<t6pCy-4Bc-17@gated-at.bofh.it>
Here, If ioremap_nocache will fail. It will return NULL.
Kernel can run into a NULL-pointer dereference.
This error check will avoid NULL pointer dereference.

If kzalloc will fail return -ENOMEM instead of '1'.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/parisc/ccio-dma.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c
index 553ef8a..b0558e2 100644
--- a/drivers/parisc/ccio-dma.c
+++ b/drivers/parisc/ccio-dma.c
@@ -1539,7 +1539,7 @@ static int __init ccio_probe(struct parisc_device *dev)
 	ioc = kzalloc(sizeof(struct ioc), GFP_KERNEL);
 	if (ioc == NULL) {
 		printk(KERN_ERR MODULE_NAME ": memory allocation failure\n");
-		return 1;
+		return -ENOMEM;
 	}
 
 	ioc->name = dev->id.hversion == U2_IOA_RUNWAY ? "U2" : "UTurn";
@@ -1554,6 +1554,10 @@ static int __init ccio_probe(struct parisc_device *dev)
 
 	ioc->hw_path = dev->hw_path;
 	ioc->ioc_regs = ioremap_nocache(dev->hpa.start, 4096);
+	if (!ioc->ioc_regs) {
+		kfree(ioc);
+		return -ENOMEM;
+	}
 	ccio_ioc_init(ioc);
 	ccio_init_resources(ioc);
 	hppa_dma_ops = &ccio_ops;
-- 
1.9.1

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web