Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1922150iob; Fri, 29 Apr 2022 16:30:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw07Qsc92HTdKJh2XTUlFWrRi7zaSvmbN87PWFhXcAkwgy6J4wHsQ3hv/AdrQS4KeJsNOEj X-Received: by 2002:a17:90b:1e47:b0:1da:31f9:e5d1 with SMTP id pi7-20020a17090b1e4700b001da31f9e5d1mr6444906pjb.226.1651275055653; Fri, 29 Apr 2022 16:30:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651275055; cv=none; d=google.com; s=arc-20160816; b=RISQc0Wodyg6FoUgtRibookEzbQ7Rr7Qu1JFOwnVaaD6Du+p6iDKS6CvOY7NBmkGFq mKYeB1X0twpT8fo33isMeDbjpvwFKuK95SP84A4wPZPp1jyW+bCzh2HejJg64ToemF+P 43tyWbq1c5gmssF64ZPibLNBu+wGB4rioViSN6Pht9i5g8C1otTs9620B+V323lXbyGL V+sMnctjJzJ9VXvy/xwgXHlV7H6yYySlpMDQF1/LtYBa4NmO7I8WPbheXSHiAmjkyKZY 2bF5eJbTLOH9D6aOuG7YOnubJLBSBu3Ld1VDAtqlWqyDcxvsamb3bc21yXKys817oPpD Y57A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=u1zr0ocp/rvoUcR4FFggSS+wd0naXcvHjwQhpBmQZJ4=; b=MU/+1oj20hdYVC4oZgYEAh8PFaVuF0qY/VHK7oFAMwRNScjyCsvO0ttbCzOTynkDLc 5LP16TpBWlYZowXpAxMddUrQjk4CSbZrha3XTVlbOsDcqRJysK64p3txnqb3NWOAbxfS 5+mP4I47tbZfJl9zOYe9TMXmtW6xLGJouY4p+KbZYwgdVbr+6fV4wCfXL+hAnXw3O41e qY99WNylApirXF8x1+fIEa39S/zCUISSJ830D+OFUO++PFLP+pBT1HzE1PNBkjZhvBL3 WUV1wtShEIM0prkHolpLR7Ty7Rbvr50YYgg1yBYeSmH2KAoXm61md8040mJnC2VYRmb+ 23yg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q17-20020a63e211000000b003abada6a561si8285823pgh.303.2022.04.29.16.30.39; Fri, 29 Apr 2022 16:30:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355304AbiD2H7M (ORCPT + 99 others); Fri, 29 Apr 2022 03:59:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355298AbiD2H7F (ORCPT ); Fri, 29 Apr 2022 03:59:05 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 903814ECF6; Fri, 29 Apr 2022 00:55:47 -0700 (PDT) Received: from dggpemm500021.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KqPt95v5szhYkp; Fri, 29 Apr 2022 15:55:29 +0800 (CST) Received: from dggpemm500007.china.huawei.com (7.185.36.183) by dggpemm500021.china.huawei.com (7.185.36.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 29 Apr 2022 15:55:45 +0800 Received: from huawei.com (10.175.103.91) by dggpemm500007.china.huawei.com (7.185.36.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 29 Apr 2022 15:55:44 +0800 From: Yang Yingliang To: , , CC: , Subject: [PATCH] PCI: qcom-ep: check return value after calling platform_get_resource_byname() Date: Fri, 29 Apr 2022 16:07:40 +0800 Message-ID: <20220429080740.1294797-1-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If platform_get_resource_byname() fails, 'mmio_res' will be set to null pointer, it will cause null-ptr-deref when it used in qcom_pcie_perst_deassert(), so we need check the return value. Fixes: f55fee56a631 ("PCI: qcom-ep: Add Qualcomm PCIe Endpoint controller driver") Signed-off-by: Yang Yingliang --- drivers/pci/controller/dwc/pcie-qcom-ep.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-qcom-ep.c b/drivers/pci/controller/dwc/pcie-qcom-ep.c index 6ce8eddf3a37..becb0c2ff870 100644 --- a/drivers/pci/controller/dwc/pcie-qcom-ep.c +++ b/drivers/pci/controller/dwc/pcie-qcom-ep.c @@ -416,6 +416,10 @@ static int qcom_pcie_ep_get_io_resources(struct platform_device *pdev, pcie_ep->mmio_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mmio"); + if (!pcie_ep->mmio_res) { + dev_err(dev, "Failed to get mmio resource\n"); + return -EINVAL; + } syscon = of_parse_phandle(dev->of_node, "qcom,perst-regs", 0); if (!syscon) { -- 2.25.1