From patchwork Tue May 2 07:06:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 98404 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp1742041qgf; Tue, 2 May 2017 00:12:19 -0700 (PDT) X-Received: by 10.84.175.129 with SMTP id t1mr39552946plb.190.1493709139342; Tue, 02 May 2017 00:12:19 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 23si16197230pga.229.2017.05.02.00.12.19; Tue, 02 May 2017 00:12:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752115AbdEBHMH (ORCPT + 25 others); Tue, 2 May 2017 03:12:07 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:5910 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750823AbdEBHMC (ORCPT ); Tue, 2 May 2017 03:12:02 -0400 Received: from 172.30.72.56 (EHLO dggeml405-hub.china.huawei.com) ([172.30.72.56]) by dggrg03-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id AMW20348; Tue, 02 May 2017 15:11:51 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by dggeml405-hub.china.huawei.com (10.3.17.49) with Microsoft SMTP Server id 14.3.301.0; Tue, 2 May 2017 15:11:42 +0800 From: Hanjun Guo To: Thomas Gleixner , Marc Zyngier CC: Kefeng Wang , Wei Yongjun , MaJun , , Hanjun Guo Subject: [PATCH 1/3] irqchip/mbigen: Fix memory mapping code Date: Tue, 2 May 2017 15:06:34 +0800 Message-ID: <1493708796-43561-1-git-send-email-guohanjun@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.59083140.010B, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: b7b30f97c8808a72df17918c9df14e59 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hanjun Guo Some mbigens share memory regions, and devm_ioremap_resource does not allow to share resources which will break the probe of mbigen, in opposition to devm_ioremap. This patch restores back usage of devm_ioremap function, but with proper error handling and logging. Fixes: 216646e4d82e ("irqchip/mbigen: Fix return value check in mbigen_device_probe()") Signed-off-by: Hanjun Guo --- drivers/irqchip/irq-mbigen.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 1.7.12.4 diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c index d2306c8..e1d99f4 100644 --- a/drivers/irqchip/irq-mbigen.c +++ b/drivers/irqchip/irq-mbigen.c @@ -337,9 +337,12 @@ static int mbigen_device_probe(struct platform_device *pdev) mgn_chip->pdev = pdev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - mgn_chip->base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(mgn_chip->base)) - return PTR_ERR(mgn_chip->base); + mgn_chip->base = devm_ioremap(&pdev->dev, res->start, + resource_size(res)); + if (!mgn_chip->base) { + dev_err(&pdev->dev,"failed to ioremap %pR\n", res); + return -ENOMEM; + } if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) err = mbigen_of_create_domain(pdev, mgn_chip); From patchwork Tue May 2 07:06:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 98405 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp1742049qgf; Tue, 2 May 2017 00:12:20 -0700 (PDT) X-Received: by 10.98.223.5 with SMTP id u5mr30904991pfg.147.1493709140824; Tue, 02 May 2017 00:12:20 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 23si16197230pga.229.2017.05.02.00.12.19; Tue, 02 May 2017 00:12:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752137AbdEBHMQ (ORCPT + 25 others); Tue, 2 May 2017 03:12:16 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:5911 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750823AbdEBHMN (ORCPT ); Tue, 2 May 2017 03:12:13 -0400 Received: from 172.30.72.56 (EHLO dggeml405-hub.china.huawei.com) ([172.30.72.56]) by dggrg03-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id AMW20349; Tue, 02 May 2017 15:11:51 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by dggeml405-hub.china.huawei.com (10.3.17.49) with Microsoft SMTP Server id 14.3.301.0; Tue, 2 May 2017 15:11:42 +0800 From: Hanjun Guo To: Thomas Gleixner , Marc Zyngier CC: Kefeng Wang , Wei Yongjun , MaJun , , Hanjun Guo Subject: [PATCH 2/3] irqchip/mbigen: Fix potential NULL dereferencing Date: Tue, 2 May 2017 15:06:35 +0800 Message-ID: <1493708796-43561-2-git-send-email-guohanjun@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1493708796-43561-1-git-send-email-guohanjun@huawei.com> References: <1493708796-43561-1-git-send-email-guohanjun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.59083141.0021, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 9f623d4ffbd8dc96b16febfa2d7948d3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hanjun Guo platform_get_resource() may return NULL, add proper check to avoid potential NULL dereferencing. Signed-off-by: Hanjun Guo --- drivers/irqchip/irq-mbigen.c | 3 +++ 1 file changed, 3 insertions(+) -- 1.7.12.4 diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c index e1d99f4..167cdb5 100644 --- a/drivers/irqchip/irq-mbigen.c +++ b/drivers/irqchip/irq-mbigen.c @@ -337,6 +337,9 @@ static int mbigen_device_probe(struct platform_device *pdev) mgn_chip->pdev = pdev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -EINVAL; + mgn_chip->base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); if (!mgn_chip->base) {