From patchwork Thu Feb 2 13:22:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arvind Yadav X-Patchwork-Id: 9551801 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 90ECF604E1 for ; Thu, 2 Feb 2017 13:23:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D92D28329 for ; Thu, 2 Feb 2017 13:23:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 509832839A; Thu, 2 Feb 2017 13:23:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 267D828329 for ; Thu, 2 Feb 2017 13:23:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751156AbdBBNXd (ORCPT ); Thu, 2 Feb 2017 08:23:33 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:36743 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750873AbdBBNXb (ORCPT ); Thu, 2 Feb 2017 08:23:31 -0500 Received: by mail-io0-f195.google.com with SMTP id q20so24079691ioi.3; Thu, 02 Feb 2017 05:23:30 -0800 (PST) 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) Received: from symbol-HP-Z420-Workstation.zebra.lan ([223.31.70.102]) by smtp.googlemail.com with ESMTPSA id k16sm875196itk.2.2017.02.02.05.23.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 Feb 2017 05:23:29 -0800 (PST) From: Arvind Yadav To: deller@gmx.de Cc: linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] parisc: ccio-dma: Handle return NULL error from ioremap_nocache Date: Thu, 2 Feb 2017 18:52:34 +0530 Message-Id: <1486041754-12996-1-git-send-email-arvind.yadav.cs@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;