From patchwork Sat Jul 22 07:33:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 792451 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xDztM5SDTz9s8P for ; Sat, 22 Jul 2017 17:34:51 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3xDztM4Sq4zDqxy for ; Sat, 22 Jul 2017 17:34:51 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3xDzsC6Bk7zDqpV for ; Sat, 22 Jul 2017 17:33:51 +1000 (AEST) Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v6M7Xl8B015120 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 22 Jul 2017 07:33:48 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v6M7XiHI016812 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 22 Jul 2017 07:33:47 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v6M7XhBA010105; Sat, 22 Jul 2017 07:33:44 GMT Received: from mwanda (/197.254.35.146) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 22 Jul 2017 00:33:43 -0700 Date: Sat, 22 Jul 2017 10:33:35 +0300 From: Dan Carpenter To: Qiang Zhao Subject: [PATCH 1/2] fsl/qe: NULL dereference on error in ucc_of_parse_tdm() Message-ID: <20170722073335.tb6byaaarqvloh3a@mwanda> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: NeoMutt/20170609 (1.8.3) X-Source-IP: userv0022.oracle.com [156.151.31.74] X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel-janitors@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Li Yang Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" If "pdev = of_find_device_by_node(np2);" fails then it would lead to a NULL dereference. This function is called from probe() and we're using managed resources so we can just return without doing a manual cleanup. Fixes: 35ef1c20fdb2 ("fsl/qe: Add QE TDM lib") Signed-off-by: Dan Carpenter diff --git a/drivers/soc/fsl/qe/qe_tdm.c b/drivers/soc/fsl/qe/qe_tdm.c index f744c214f680..ec7a853053c3 100644 --- a/drivers/soc/fsl/qe/qe_tdm.c +++ b/drivers/soc/fsl/qe/qe_tdm.c @@ -139,32 +139,25 @@ int ucc_of_parse_tdm(struct device_node *np, struct ucc_tdm *utdm, of_node_put(np2); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); utdm->si_regs = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(utdm->si_regs)) { - ret = PTR_ERR(utdm->si_regs); - goto err_miss_siram_property; - } + if (IS_ERR(utdm->si_regs)) + return PTR_ERR(utdm->si_regs); np2 = of_find_compatible_node(NULL, NULL, "fsl,t1040-qe-siram"); - if (!np2) { - ret = -EINVAL; - goto err_miss_siram_property; - } + if (!np2) + return -EINVAL; pdev = of_find_device_by_node(np2); if (!pdev) { - ret = -EINVAL; pr_err("%s: failed to lookup pdev\n", np2->name); of_node_put(np2); - goto err_miss_siram_property; + return -EINVAL; } of_node_put(np2); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); utdm->siram = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(utdm->siram)) { - ret = PTR_ERR(utdm->siram); - goto err_miss_siram_property; - } + if (IS_ERR(utdm->siram)) + return PTR_ERR(utdm->siram); if (siram_init_flag == 0) { memset_io(utdm->siram, 0, resource_size(res)); @@ -172,10 +165,6 @@ 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); - return ret; } EXPORT_SYMBOL(ucc_of_parse_tdm);