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


Groups > linux.kernel > #1572349

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

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From Arvind Yadav <arvind.yadav.cs@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] parisc: ccio-dma: Handle return NULL error from ioremap_nocache
Date Thu, 02 Feb 2017 14:30:02 +0100
Message-ID <t6pCy-4Bc-17@gated-at.bofh.it> (permalink)
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=KGtK8TNzYW+G6Xt20g7ZKaUOmtoSyvrlMlsE/hnh5dM=; b=gTY9hbDrRD0oFapBe0TFP/0vcb+1/m3dQpZPF6LwV7xMhuUivT81zftzfM+GKQCiVk ETPOVsQ6Jjo65SzonpQlIhM21egncdOCKRIlgHWQy8fad4HFgkPL8M3QyxhCRmVqMaYL tNb3Ge3vwabxJvqYYjWUpuPN6+t5VVg0dlnKh56/7IT9thIFpXxBNgMtYWcQ92LhJyvg nkK+H1LjeDKwoJ37pv5UR/IOGT0O1mvS1WffwKyFXbjDC+0LycLGbeEPa2JJqhIubwUb KaBoBbC59oZwIhAhPtqv06MpYNwmeaROQod1jmxQBAyHi2oxQhRNpEJxXRREL4A8mXvN ZZSQ==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=KGtK8TNzYW+G6Xt20g7ZKaUOmtoSyvrlMlsE/hnh5dM=; b=Pfyy/QwqQauU0pYT59FfGSRjFHn/rXZW1qPNE4Fr5/zHMViolmiHcVnCGvcf5C6DnR 2AwtctEFMJWK9Z6x1tL/GLLdzXsCAYs3W163ElI7m4OSF0sovrWxrd1FrOMs0BWEcHFw oqywHD7lAsZmWD2vF8PmuFMQ8AwWqbe0OdYp/hdxX1mz2ZrYLygbIDG3SYn+lsQ1MK8Q 1oU7cjziDUqzfCmBA59+5LbOA3vineNJL7/YLqwk7IShaKb1OetcirSUhC2bROxoSsSC Rgd7LWbLKg4DYX21kWp1RQ3/0sj4f5GkPQRl6eGUAp6EhczFIl1J67bq3TlxpmXf2FEV YWLg==
X-Gm-Message-State AIkVDXJczXRhbtMPrjEAlBuFRQ2LkrOIFMB3De4uGekSyM9Xhm/f0dzExky2x+JnMi8Znw==
X-Received by 10.107.11.27 with SMTP id v27mr6245734ioi.145.1486041810128; Thu, 02 Feb 2017 05:23:30 -0800 (PST)
X-Mailer git-send-email 1.9.1
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 37
Organization linux.* mail to news gateway
X-Original-Cc linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org
X-Original-Date Thu, 2 Feb 2017 18:52:34 +0530
X-Original-Message-ID <1486041754-12996-1-git-send-email-arvind.yadav.cs@gmail.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1572349

Show key headers only | View raw


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

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web