From patchwork Fri Oct 21 10:57:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaehoon Chung X-Patchwork-Id: 9388693 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 41B2160231 for ; Fri, 21 Oct 2016 10:58:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32DD52A05F for ; Fri, 21 Oct 2016 10:58:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26D5B2A064; Fri, 21 Oct 2016 10:58:06 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 5A7A02A05F for ; Fri, 21 Oct 2016 10:58:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932162AbcJUK6E (ORCPT ); Fri, 21 Oct 2016 06:58:04 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:55887 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754307AbcJUK6D (ORCPT ); Fri, 21 Oct 2016 06:58:03 -0400 Received: from epcpsbgm2new.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OFE02ZZV94PLK20@mailout2.samsung.com>; Fri, 21 Oct 2016 19:58:01 +0900 (KST) X-AuditID: cbfee61b-f79b66d000002d5f-6c-5809f4b9d740 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id 0E.53.11615.9B4F9085; Fri, 21 Oct 2016 19:58:01 +0900 (KST) Received: from localhost.localdomain ([10.113.62.216]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OFE00FCV94PBO00@mmp1.samsung.com>; Fri, 21 Oct 2016 19:58:01 +0900 (KST) From: Jaehoon Chung To: linux-mmc@vger.kernel.org Cc: ulf.hansson@linaro.org, shawn.lin@rock-chips.com, stable@vger.kernel.org, gregkh@linuxfoundation.org, Jaehoon Chung Subject: [PATCH] mmc: dw_mmc-pltfm: fix the potential NULL pointer dereference Date: Fri, 21 Oct 2016 19:57:57 +0900 Message-id: <20161021105757.22712-1-jh80.chung@samsung.com> X-Mailer: git-send-email 2.10.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrPLMWRmVeSWpSXmKPExsVy+t9jAd2dXzgjDG5tUbVoXryezeLGrzZW iyP/+xkt7jxZz2qxYOMjRovja8Md2DzuXNvD5rF/7hp2j7+z9rN49G1ZxejxeZNcAGuUm01G amJKapFCal5yfkpmXrqtUmiIm66FkkJeYm6qrVKErm9IkJJCWWJOKZBnZIAGHJwD3IOV9O0S 3DLmvlYoWMlR8fjQRbYGxlb2LkZODgkBE4mlU9qgbDGJC/fWs3UxcnEICSxllNh58zY7hPOD UaJr22YWkCo2AR2J7d+OM4HYIgKyEj//XADrYBaYxChx7cVaVpCEsICfxIfJu8CKWARUJW4+ mMoIYvMKWEt83rKNEWKdvMSFq6dYJjByL2BkWMUokVqQXFCclJ5rlJdarlecmFtcmpeul5yf u4kRHJjPpHcwHt7lfohRgINRiYdX4x1nhBBrYllxZe4hRgkOZiURXr/PQCHelMTKqtSi/Pii 0pzU4kOMpkAHTGSWEk3OB0ZNXkm8oYm5ibmxgYW5paWJkZI4b+PsZ+FCAumJJanZqakFqUUw fUwcnFINjBoBoTK8y84IPmXf6SUeJGuz+koS59O0EidVR5vTjx6v6ljXlcsnqxu3Zp1N3VTt X4sOy0bFyhWKyggr3amaXfu/a9sy9Tf9BzZycy3R6mdueq+csjz86l39dGF+RsW46c9aEj5e lhe152PbfyqPr9F2f0Tmq+9z3ryvu+Aj0fo9+UtuqsleJZbijERDLeai4kQA4ZWjCWICAAA= X-MTR: 20000000000000000@CPGS Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP platform_get_resource can be returned the NULL pointer. Then regs->start should be referred to NULL Pointer. devm_ioremap_resource() checks whether res is NULL or not. Signed-off-by: Jaehoon Chung Reviewed-by: Shawn Lin --- drivers/mmc/host/dw_mmc-pltfm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/dw_mmc-pltfm.c b/drivers/mmc/host/dw_mmc-pltfm.c index b486fef..1236d49b 100644 --- a/drivers/mmc/host/dw_mmc-pltfm.c +++ b/drivers/mmc/host/dw_mmc-pltfm.c @@ -47,12 +47,13 @@ int dw_mci_pltfm_register(struct platform_device *pdev, host->pdata = pdev->dev.platform_data; regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); - /* Get registers' physical base address */ - host->phy_regs = regs->start; host->regs = devm_ioremap_resource(&pdev->dev, regs); if (IS_ERR(host->regs)) return PTR_ERR(host->regs); + /* Get registers' physical base address */ + host->phy_regs = regs->start; + platform_set_drvdata(pdev, host); return dw_mci_probe(host); }