Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp67464ybt; Mon, 6 Jul 2020 04:17:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1VSit3TDz8hjfnGMloPRwLHg+HS0FTfJzcKkdnGACoe6bRuJUPUo2bQ/WN5y/kAb4vLWb X-Received: by 2002:aa7:cdca:: with SMTP id h10mr42120767edw.285.1594034277086; Mon, 06 Jul 2020 04:17:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594034277; cv=none; d=google.com; s=arc-20160816; b=uzHWifCsCaxoq8AhFpeqs+ydKe9AhznkYJJq9VrkeKtGNYbFcRnGIZnG3vvosRrxTT QwTiAXrD5ZI+LTVD5dgtmifvEOrBY1J0RjbENf1HaBCsRS//MnCol2Y1NmBjapzr7u6b Q0ImE8EMGAzxVW18e+4TbgJk5GAdCmSs+JVC03mfkYR9/2U1svNcSel+yBy+MrEzw7qO r8x7Ma7CfsJB9EvY8/ZioP2YoNguP98zPKD7Yq+Cz4Q1puAudi6tdEJF6iGyQ/6F5yrk /1XfWYINgJtX/kkpqKMJaZY9pq5hvIv2/DB2P5mQaJOurWCJYodLrlvCz22UiXvTvUXs X6/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=vt2K4FHgCEEcyRqiAfL3q2BnpuAHetS6gSidLZy4SOY=; b=0wsV8oC9y/ECOAaaoVLQK/W/1lxVQgFhGQunRKqmur3RYRnM22wGrI0rqtluZ7zqdV K63mqKGs92LLa7Z6ai3pihr42nRrSXq1macaBMX78P3n9Z6Ucqw0w/dvi23GmlZVOPgy Kouw0HOZ03MJTsu4KlKmH0bEPKJVVWVc4+BGSNvngKvyOcOPeT5ahIqhjsXCBiQSKZw2 I0yj+u4AnZo25dBDkUtnwrQ10xrKuFL9coPGw4/AGQ5qHHJltYzB1Pw7eg5Kyg5gKmBh /4N7cJizWEb8mdFnBVbf4IsiqR3NmvT/e/jkhKeU28Lf743ugxLguYS54J+wYS8Kaiso IAPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d18si12878223edy.194.2020.07.06.04.17.31; Mon, 06 Jul 2020 04:17:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728892AbgGFLRO (ORCPT + 99 others); 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 > > > > > > >