From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 085D2C433E0 for ; Mon, 6 Jul 2020 11:17:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D31E520724 for ; Mon, 6 Jul 2020 11:17:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728697AbgGFLRO (ORCPT ); Mon, 6 Jul 2020 07:17:14 -0400 Received: from foss.arm.com ([217.140.110.172]:58752 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728578AbgGFLRN (ORCPT ); Mon, 6 Jul 2020 07:17:13 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 30A40C0A; Mon, 6 Jul 2020 04:17:12 -0700 (PDT) Received: from e121166-lin.cambridge.arm.com (e121166-lin.cambridge.arm.com [10.1.196.255]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 31A3F3F68F; Mon, 6 Jul 2020 04:17:11 -0700 (PDT) Date: Mon, 6 Jul 2020 12:17:08 +0100 From: Lorenzo Pieralisi To: Sriram Dash Cc: 'Kishon Vijay Abraham I' , 'Shradha Todi' , bhelgaas@google.com, pankaj.dubey@samsung.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] PCI: endpoint: Fix NULL pointer dereference for ->get_features() Message-ID: <20200706111708.GF26377@e121166-lin.cambridge.arm.com> References: <20200311102852.5207-1-shradha.t@samsung.com> <000d01d5fdf3$55d43af0$017cb0d0$@samsung.com> <000001d608fb$7ab39010$701ab030$@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000001d608fb$7ab39010$701ab030$@samsung.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Thu, Apr 02, 2020 at 08:01:59PM +0530, Sriram Dash wrote: [...] > > So the patch itself is correct though the commit log has to be fixed. You should > > also check if all the endpoint controller drivers existing currently provides > > epc_features. > > At the moment, there is no issue for existing controller drivers as I > can see almost all drivers are providing epc_features. But, this is > not a mandatory feature and some controller drivers may not have > epc_features implemented, may be in the near future. But because we > are dealing with the configfs, the application need not bother about > the driver details underneath. > > IMO, the code should be fixed regardless and should not cause panic in > any case. What's this patch status please ? Thanks, Lorenzo > > Thanks > > Kishon > > > > > > > > >> drivers/pci/endpoint/functions/pci-epf-test.c | 15 +++++++++------ > > >> 1 file changed, 9 insertions(+), 6 deletions(-) > > >> > > >> 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 > > >> @@ -510,14 +510,17 @@ static int pci_epf_test_bind(struct pci_epf *epf) > > >> return -EINVAL; > > >> > > >> epc_features = pci_epc_get_features(epc, epf->func_no); > > >> - if (epc_features) { > > >> - linkup_notifier = epc_features->linkup_notifier; > > >> - msix_capable = epc_features->msix_capable; > > >> - msi_capable = epc_features->msi_capable; > > >> - test_reg_bar = pci_epc_get_first_free_bar(epc_features); > > >> - pci_epf_configure_bar(epf, epc_features); > > >> + if (!epc_features) { > > >> + dev_err(dev, "epc_features not implemented\n"); > > >> + return -ENOTSUPP; > > >> } > > >> > > >> + linkup_notifier = epc_features->linkup_notifier; > > >> + msix_capable = epc_features->msix_capable; > > >> + msi_capable = epc_features->msi_capable; > > >> + test_reg_bar = pci_epc_get_first_free_bar(epc_features); > > >> + pci_epf_configure_bar(epf, epc_features); > > >> + > > >> epf_test->test_reg_bar = test_reg_bar; > > >> epf_test->epc_features = epc_features; > > >> > > >> -- > > >> 2.17.1 > > > > > > >