From patchwork Wed Nov 21 07:41:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Yang X-Patchwork-Id: 10692063 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 071FF13AD for ; Wed, 21 Nov 2018 07:41:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8EB82B734 for ; Wed, 21 Nov 2018 07:41:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DCF7F2B799; Wed, 21 Nov 2018 07:41:03 +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=-3.4 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW,SUBJ_OBFU_PUNCT_MANY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 2A2402B734 for ; Wed, 21 Nov 2018 07:41:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=iLywB7IZTzjKsmZJLInyHdStzZC8ZfjJji1g//nYuCs=; b=Rq2 a9ixf1GjDRp0OrN48lUnx2Oecdu0CSOJRkEqklS+/Y0IZoagCNmECHg8xVhrJ/s+strLsm+ZtuLr4 5vP+NWBx7KyP1d6TjDy4tQhjWxXCDpwccINgboFGBdwf1ZP90rNdTZO9D5WNcYfUYXArtHfNY48eH R7fWeNLy36svjmbLZjP9cmkmCAxROsS12iHWkwPRkhSsSdl1JcTXkXT2p22jdk/wT3nv8XOB8pdvk yk0BBPRus3+5tA2qGFr/rlO8feJgQGhVgmHj4vKba0YBUhWN8dOu4CXoHtZJonEortuAG50N80jFT OMPhyFcKCXSrP3k9aiT/0Rnt8WdW4YQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gPN89-00078V-Lk; Wed, 21 Nov 2018 07:41:01 +0000 Received: from out1.zte.com.cn ([202.103.147.172] helo=mxct.zte.com.cn) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gPN86-00077Y-2Q for linux-arm-kernel@lists.infradead.org; Wed, 21 Nov 2018 07:41:00 +0000 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 89D153EA44BEDCCA6676; Wed, 21 Nov 2018 15:40:39 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id wAL7eQIG084734; Wed, 21 Nov 2018 15:40:26 +0800 (GMT-8) (envelope-from wen.yang99@zte.com.cn) Received: from fox-host8.localdomain ([10.74.120.8]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2018112115404502-12071388 ; Wed, 21 Nov 2018 15:40:45 +0800 From: Wen Yang To: qiang.zhao@nxp.com Subject: [PATCH 2/4] soc/fsl/qe: fix potential NULL pointer dereference in ucc_of_parse_tdm Date: Wed, 21 Nov 2018 15:41:51 +0800 Message-Id: <1542786111-18648-1-git-send-email-wen.yang99@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2018-11-21 15:40:45, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-11-21 15:40:18, Serialize complete at 2018-11-21 15:40:18 X-MAIL: mse01.zte.com.cn wAL7eQIG084734 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181120_234058_272108_29F6A6B8 X-CRM114-Status: GOOD ( 11.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: wang.yi59@zte.com.cn, zhong.weidong@zte.com.cn, linux-kernel@vger.kernel.org, leoyang.li@nxp.com, Julia Lawall , linuxppc-dev@lists.ozlabs.org, wen.yang99@zte.com.cn, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes a possible null pointer dereference in ucc_of_parse_tdm, detected by the semantic patch deref_null.cocci, with the following warning: ./drivers/soc/fsl/qe/qe_tdm.c:177:21-24: ERROR: pdev is NULL but dereferenced. The following code has potential null pointer references: pdev = of_find_device_by_node(np2); if (!pdev) { ret = -EINVAL; pr_err("%pOFn: failed to lookup pdev\n", np2); of_node_put(np2); goto err_miss_siram_property; } ... err_miss_siram_property: devm_iounmap(&pdev->dev, utdm->si_regs); Signed-off-by: Wen Yang Reviewed-by: Tan Hu CC: Julia Lawall --- drivers/soc/fsl/qe/qe_tdm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/soc/fsl/qe/qe_tdm.c b/drivers/soc/fsl/qe/qe_tdm.c index f78c346..166378b 100644 --- a/drivers/soc/fsl/qe/qe_tdm.c +++ b/drivers/soc/fsl/qe/qe_tdm.c @@ -174,7 +174,8 @@ int ucc_of_parse_tdm(struct device_node *np, struct ucc_tdm *utdm, return ret; err_miss_siram_property: - devm_iounmap(&pdev->dev, utdm->si_regs); + if (pdev) + devm_iounmap(&pdev->dev, utdm->si_regs); return ret; } EXPORT_SYMBOL(ucc_of_parse_tdm);