From patchwork Fri Jan 27 11:17:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: shailendra.v@samsung.com X-Patchwork-Id: 9541329 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 E8D0D601D7 for ; Fri, 27 Jan 2017 11:18:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D77B4252D5 for ; Fri, 27 Jan 2017 11:18:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAD4627FC0; Fri, 27 Jan 2017 11:18:52 +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=-1.9 required=2.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 92D86252D5 for ; Fri, 27 Jan 2017 11:18:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cX4YN-0004Bb-N8; Fri, 27 Jan 2017 11:18:51 +0000 Received: from mailout2.samsung.com ([203.254.224.25]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cX4Xq-0003t3-SU; Fri, 27 Jan 2017 11:18:20 +0000 Received: from epcas4p3.samsung.com (unknown [182.195.41.33]) by mailout2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OKF02SEDRDWR420@mailout2.samsung.com>; Fri, 27 Jan 2017 20:17:56 +0900 (KST) Received: from epsmges4p4.samsung.com (unknown [182.195.42.36]) by epcas4p1.samsung.com (KnoxPortal) with ESMTP id 20170127111755epcas4p1ec096fd3b663dbfe25a418de6b595980~dnNF50Ezx2590125901epcas4p18; Fri, 27 Jan 2017 11:17:55 +0000 (GMT) Received: from epcas4p1.samsung.com ( [182.195.41.31]) by epsmges4p4.samsung.com (EPCPMTA) with SMTP id B1.FF.06699.36C2B885; Fri, 27 Jan 2017 20:17:55 +0900 (KST) Received: from epsmgmsp04.samsung.com (unknown [182.195.34.25]) by epcas4p4.samsung.com (KnoxPortal) with ESMTP id 20170127111755epcas4p4f4bf0401e49ddd4563b0365b838d3dde~dnNFtjfhx3180231802epcas4p4Q; Fri, 27 Jan 2017 11:17:55 +0000 (GMT) X-AuditID: b6c32a24-f79ea6d000001a2b-7f-588b2c635e61 Received: from srin.p4 (Unknown_Domain [107.108.168.37]) by epsmgmsp04.samsung.com (EPCPMTA) with SMTP id 9A.CC.04872.16C2B885; Fri, 27 Jan 2017 20:17:55 +0900 (KST) From: Shailendra Verma To: Matthias Brugger , John Crispin , Henry Chen , Daniel Kurtz , Arnd Bergmann , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, p.shailesh@samsung.com, ashish.kalra@samsung.com, Shailendra Verma , Shailendra Verma Subject: [PATCH] Soc: mediatek - Fix possible NULL derefrence. Date: Fri, 27 Jan 2017 16:47:48 +0530 Message-id: <1485515868-3671-1-git-send-email-shailendra.v@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGIsWRmVeSWpSXmKPExsWy7bCmvG6yTneEwZm1ShZ/Jx1jt7g/7Ru7 xcnmG4wWjTPms1rc/T6LyWLT42usFpd3zWGzuNx8kdGiqcXYYseUVhaLW/Nmslks+vaK2YHH 4/evSYwesxsusnjsnHWX3WPzknqPlpP7WTy2LM7w6NuyitHj8ya5AI4oLpuU1JzMstQif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NLNG5fQVYkbCAncSE67fBmlkEVCWWbt8GFOfg4BVwl1h8LQzElBBQkJgzyWYCI+cCRoZV jGKpBcW56bnFBQYmesWJucWleel6yfm5mxiBIbvtsJLkDsZVK7wOMQpwMCrx8O7Y1xUhxJpY VlyZe4hRgoNZSYRXV6w7Qog3JbGyKrUoP76oNCe1+BCjKdDyicxSosn5wHjKK4k3NDG1sLAw sTQ2NrYwURLnjZ3+LFxIID2xJDU7NbUgtQimj4mDU6qBcYJf/jGXVMEl3JHeLMHv433EWp/f fFZ6iZNLOLJHbVGRE9PbwNoVz0rqDX4xpiZNXF4jcM3iYdv97ZVuc0vsc303W/MafryTp8Ed L7qlfGv4gW7OuT5CmQUmpr1CR0/VufuEljW76iUuaXn9+V8F57lD/XK5s97nP94yJesin8TR 2VufXpmkxFKckWioxVxUnAgAj7sOeG8CAAA= X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170127111755epcas4p4f4bf0401e49ddd4563b0365b838d3dde X-Msg-Generator: CA X-Sender-IP: 182.195.34.25 X-Local-Sender: =?UTF-8?B?U2hhaWxlbmRyYSBWZXJtYRtTUkktTm9pZGEtQ29tbWVyY2lh?= =?UTF-8?B?bCBSJkQgIFN5c3RlbSBTL1cgR3JvdXAb7IK87ISx7KCE7J6QG0xlYWQgRW5n?= =?UTF-8?B?aW5lZXIvQ29ycG9yYXRlIEVuZ2luZWVy?= X-Global-Sender: =?UTF-8?B?U2hhaWxlbmRyYSBWZXJtYRtTUkktTm9pZGEtQ29tbWVyY2lh?= =?UTF-8?B?bCBSJkQgIFN5c3RlbSBTL1cgR3JvdXAbU2Ftc3VuZyBFbGVjdHJvbmljcxtM?= =?UTF-8?B?ZWFkIEVuZ2luZWVyL0NvcnBvcmF0ZSBFbmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG1NXQUhRG0MxMElaMDFJWjAxODEyMA==?= CMS-TYPE: 104P X-HopCount: 7 X-CMS-RootMailID: 20170127111755epcas4p4f4bf0401e49ddd4563b0365b838d3dde X-RootMTR: 20170127111755epcas4p4f4bf0401e49ddd4563b0365b838d3dde References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170127_031819_085625_D49E9A05 X-CRM114-Status: UNSURE ( 9.47 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP of_match_device could return NULL, and so can cause a NULL pointer dereference later. Signed-off-by: Shailendra Verma --- drivers/soc/mediatek/mtk-pmic-wrap.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c index a5f1093..c48db98 100644 --- a/drivers/soc/mediatek/mtk-pmic-wrap.c +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c @@ -1117,6 +1117,11 @@ static int pwrap_probe(struct platform_device *pdev) const struct of_device_id *of_slave_id = NULL; struct resource *res; + if (!of_id) { + dev_err(&pdev->dev, "Error: No device match found\n"); + return -ENODEV; + } + if (pdev->dev.of_node->child) of_slave_id = of_match_node(of_slave_match_tbl, pdev->dev.of_node->child);