Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp662598ybg; Thu, 19 Mar 2020 06:36:38 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsdzuyuzUf2RPBWVWTbaTTLwmxXGK113ND6KAzc8UdLTxoyr6jiDwV619y0wUkjOZEehHck X-Received: by 2002:aca:3196:: with SMTP id x144mr2411545oix.77.1584624998012; Thu, 19 Mar 2020 06:36:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584624998; cv=none; d=google.com; s=arc-20160816; b=AP+C7HyZMw55qwBGiJG/kKoecxMsGROhhhBn/F2T9k3Asx/1qoqQ23VgyGzR2miXSN Q6mjN4Mqj0jTEbxg9k+u8/GPEPVRdUT9WJNScg/TLvJXgsHjgKx5w/maLsh4cJdCvnYv AlPO8uSMINHq3kniETGKKR2byQCTAJYymB9Sf62FaS5QJz8vRGs44O9o1CSEOLl/fMEt OMhKExciMAWjesmaPJZolHbIg/gIBSoLOnjIBtSPTqDhVj1sBcKBtVAds0yqEywbaOcj OpwmlxUn8vzxEjcpgZTb28MhaaZeDDXrD71hKgu7LkJkfDC94SQmPtbdHvPiqeCAIbUz rGsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:content-language :thread-index:content-transfer-encoding:mime-version:message-id:date :subject:in-reply-to:cc:to:from:dkim-signature:dkim-filter; bh=4FL33iP/jwSsQW96+6AWrtYIL4nfSj8zvnMw8LCMztg=; b=YXOoOtGNKkzbPEMqhWqaBZ6VL5HX8rKq8sOkYIyEJ5Ye43SgEfE/tdSvWkUZWDRR18 2ptyloZco3zYHazBGY6IXEOtWLlN4zUS0AgHYuvHskRLMqD3+GbVV1yGFb3iOB7YUXPB QyxG59TXxGCcQja1Xn69cJA75la+p2VCfTYZH5yC6PdpONW4fpoG8qaf0WLfZKbcsArN SL0Veaxcm0+NCS3cs+ypGHpz8ZuH8HEurfw1W/s41xxjbTbOVKJGu+vERYWf/xA+LtRN 6De2vT9d986AR5AI8xa9U900jaz62nsPhzCc91lN86/GwXEf9LYd8GLPhK+B6Wxd1Rl4 HdMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=fSS2rSdj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c22si1035897oib.266.2020.03.19.06.36.25; Thu, 19 Mar 2020 06:36:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=fSS2rSdj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727927AbgCSNgJ (ORCPT + 99 others); Thu, 19 Mar 2020 09:36:09 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:26866 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727471AbgCSNgH (ORCPT ); Thu, 19 Mar 2020 09:36:07 -0400 Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20200319133605epoutp03035693fa01ad52d33ad6a2e13cf8d146~9uAKSrzCA3266532665epoutp03M for ; Thu, 19 Mar 2020 13:36:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20200319133605epoutp03035693fa01ad52d33ad6a2e13cf8d146~9uAKSrzCA3266532665epoutp03M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1584624965; bh=4FL33iP/jwSsQW96+6AWrtYIL4nfSj8zvnMw8LCMztg=; h=From:To:Cc:In-Reply-To:Subject:Date:References:From; b=fSS2rSdjXhxn6oNDINfpNeqFPOv54i7eXTlabPA9wFEWUeYjpMCDrE/xOL5Ka4F0c 2Ofbp0cNVzjWgzBUJwQWn5/sxBt4HxwEa6gVyVgeTkj57F9AqS+203/amPEIAobaiq EqQ+7vR2Lj0VOiygkPQWo0bIWyi5JMJijmeOenxs= Received: from epsmges5p2new.samsung.com (unknown [182.195.42.74]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20200319133604epcas5p3dbbb7941cdd45bee37c4c1caa320016b~9uAJzbOTa1621316213epcas5p3E; Thu, 19 Mar 2020 13:36:04 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 83.AF.04778.445737E5; Thu, 19 Mar 2020 22:36:04 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20200319133603epcas5p294d8a6f404e5d168d75cfa6861e393e3~9uAJGi74l1782517825epcas5p2p; Thu, 19 Mar 2020 13:36:03 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200319133603epsmtrp20dd7c56c4edec8817d0b58191b050767~9uAJFqWh63159731597epsmtrp2N; Thu, 19 Mar 2020 13:36:03 +0000 (GMT) X-AuditID: b6c32a4a-353ff700000012aa-b1-5e73754435e2 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 13.C4.04024.345737E5; Thu, 19 Mar 2020 22:36:03 +0900 (KST) Received: from sriramdash03 (unknown [107.111.85.15]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200319133602epsmtip10df7c703058970433bc7f58b98daa829~9uAIAvU692963729637epsmtip1Y; Thu, 19 Mar 2020 13:36:02 +0000 (GMT) From: "Sriram Dash" To: "'Shradha Todi'" , Cc: , , , , In-Reply-To: <20200311102852.5207-1-shradha.t@samsung.com> Subject: RE: [PATCH] PCI: endpoint: Fix NULL pointer dereference for ->get_features() Date: Thu, 19 Mar 2020 19:06:01 +0530 Message-ID: <000d01d5fdf3$55d43af0$017cb0d0$@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQIRa+BXjMtyeVOz/ELce4dgT57WJwIqUA0mp8e8EHA= Content-Language: en-in X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrNKsWRmVeSWpSXmKPExsWy7bCmhq5LaXGcwdVHihZLmjIsLjztYbO4 vGsOm8XZecfZLN78fsFusWjrF3aL3sO1Duwea+atYfRYsKnUo2/LKkaP4ze2M3l83iQXwBrF ZZOSmpNZllqkb5fAldGz+wJbwTKBio/LfrE1ML7m7WLk5JAQMJF4OusPUxcjF4eQwG5Gie6n t9ghnE+MEvduPWOBcL4xSjT/esUK0/JpZQdUYi+jxNQVG1ghnFeMEuu75jGDVLEJ6EqcvdHE BmKLCNhKLN84H2wus8BkRokby3+xgyQ4BawkOvqngTUIC4RLrJh/kxHEZhFQlfh/4jYLiM0r YCkxb/tRVghbUOLkzCdgcWYBbYllC18zQ5ykIPHz6TJWiGVWEhOX3GWDqBGXOPqzhxlksYTA czaJ32+/M0E0uEhsbzwBZQtLvDq+hR3ClpL4/G4vG4SdLXG57znUghKJGa8WskDY9hIHrswB sjmAFmhKrN+lD7GLT6L39xMmkLCEAK9ER5sQRLWqxKvbm6GmS0scWHsaaquHxNcJF5gmMCrO QvLZLCSfzULywSyEZQsYWVYxSqYWFOempxabFhjlpZbrFSfmFpfmpesl5+duYgQnIS2vHYzL zvkcY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jufCm3U37G09fDLtHe+axJvxUnoHUq+dXLd7cfaBJ/VTlViK MxINtZiLihMB8/g/J6ECAAA= X-CMS-MailID: 20200319133603epcas5p294d8a6f404e5d168d75cfa6861e393e3 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" CMS-TYPE: 105P X-CMS-RootMailID: 20200311103443epcas5p2e97b8f3a8e52dc6f02eb551e0c97f132 References: <20200311102852.5207-1-shradha.t@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > From: Shradha Todi > Subject: =5BPATCH=5D PCI: endpoint: Fix NULL pointer dereference for - > >get_features() >=20 > get_features ops of pci_epc_ops may return NULL, causing NULL pointer > dereference in pci_epf_test_bind function. Let us add a check for > pci_epc_feature pointer in pci_epf_test_bind before we access it to avoid= any > such NULL pointer dereference and return -ENOTSUPP in case pci_epc_featur= e > is not found. >=20 > Reviewed-by: Pankaj Dubey > Signed-off-by: Sriram Dash > Signed-off-by: Shradha Todi > --- Hi Kishon, Any update on this? > drivers/pci/endpoint/functions/pci-epf-test.c =7C 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) >=20 > diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c > b/drivers/pci/endpoint/functions/pci-epf-test.c > index c9121b1b9fa9..af4537a487bf 100644 > --- a/drivers/pci/endpoint/functions/pci-epf-test.c > +++ b/drivers/pci/endpoint/functions/pci-epf-test.c > =40=40 -510,14 +510,17 =40=40 static int pci_epf_test_bind(struct pci_epf= *epf) > return -EINVAL; >=20 > epc_features =3D pci_epc_get_features(epc, epf->func_no); > - if (epc_features) =7B > - linkup_notifier =3D epc_features->linkup_notifier; > - msix_capable =3D epc_features->msix_capable; > - msi_capable =3D epc_features->msi_capable; > - test_reg_bar =3D pci_epc_get_first_free_bar(epc_features); > - pci_epf_configure_bar(epf, epc_features); > + if (=21epc_features) =7B > + dev_err(dev, =22epc_features not implemented=5Cn=22); > + return -ENOTSUPP; > =7D >=20 > + linkup_notifier =3D epc_features->linkup_notifier; > + msix_capable =3D epc_features->msix_capable; > + msi_capable =3D epc_features->msi_capable; > + test_reg_bar =3D pci_epc_get_first_free_bar(epc_features); > + pci_epf_configure_bar(epf, epc_features); > + > epf_test->test_reg_bar =3D test_reg_bar; > epf_test->epc_features =3D epc_features; >=20 > -- > 2.17.1