Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp6324572pxu; Wed, 23 Dec 2020 22:05:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJwt0EabnziozGHaXnp9RJQdienC+K9rd8aoqtLrp5JrnxK4EfrEN+r/Dn+f5hlJuTkv1hec X-Received: by 2002:a17:906:edd1:: with SMTP id sb17mr26377136ejb.118.1608789914790; Wed, 23 Dec 2020 22:05:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608789914; cv=none; d=google.com; s=arc-20160816; b=yT5mpEdgrSeBav3N1dmBIVMpiJ/21p3uD4acjhZ/Tn2abK9uun7QAn0PaQTXcVrJiD RG6W0RLlblnS57be7Q4DbFs/BB67rj6oX57hXO3D8sASBzdMBBA1PitYjQlltRcjXF+6 IgT14bDx5jximuo+PbgEugaqQzuFXDuSMKB5tLzh8yTGiEd/+u4AjJwmHG2j8VA2o7Qo DIalQ2kGh6MS3I/vvBSYwlC8YiLkNvcFiZ7S6P3vk6EK0YSbC7FEnEJfeUpaCWB0Znvz ctV+2lYN8YhCU4CjA6fsE/AFcdMGjFvm7ca5t55T3rSoviTD5MHLnROfh4X+EO3/TYRU ZkEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence: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=pugVbrIktDR451e/CFaYW+UN8OF55rTbO/3+HSOplXY=; b=0c5SHDuPlpyISqYnxFySXeDJKIGbeB7WLObC2wOC1CtAAmDKRsPoIbFGQhSRpuPKEG FP+IP7vTsfRSXIS6woEwIOzoAwQp2pkbrtfn+Wd6wQqpJ0iEUfwDV1hIbN4IrgfbZIiG HcteSLJUYoR2iUKqEH4UOUvMzPZ8GolX1PrVen2jrAnjmS6DeliV1TVwej2r4Y3yo72l 7A5YXvchbFIKl+d7VpnE5WLUaXN/OmLls7NNpQfeS8yL1+bXnhf3DKogpn89X9Az31VW MV8oHrzzt/iXNX2Cb9wvhOPSuXz4vlioyQ7VXxOrM/l9T1jlf2tlS+rObcYsxPDEIdQU hCrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=ruF0xuHd; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l8si12631914ejx.605.2020.12.23.22.04.52; Wed, 23 Dec 2020 22:05:14 -0800 (PST) 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; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=ruF0xuHd; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725895AbgLXGD6 (ORCPT + 99 others); Thu, 24 Dec 2020 01:03:58 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:61932 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725446AbgLXGD5 (ORCPT ); Thu, 24 Dec 2020 01:03:57 -0500 Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20201224060314epoutp04caf2bf53a11d7fe47202d1e3b6f1e997~Tkcti3D0T2259522595epoutp040 for ; Thu, 24 Dec 2020 06:03:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20201224060314epoutp04caf2bf53a11d7fe47202d1e3b6f1e997~Tkcti3D0T2259522595epoutp040 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1608789794; bh=pugVbrIktDR451e/CFaYW+UN8OF55rTbO/3+HSOplXY=; h=From:To:Cc:In-Reply-To:Subject:Date:References:From; b=ruF0xuHdR5aUKn26MzLGSQSNiRhb0mU0lUZYBScDf76m+HvQ9lwbB3pB6o6S0Z8Fg QZYeTpMsBYWtTJRxSBDf97F3jPuRHHFI4hQ9deUc9j1jT0Nwvo0B1MOWQIAFcgm+aR hgIrnW047DVPKTVWx7Sll5hMoiOFFNMKs9WxIJoE= Received: from epsmges5p2new.samsung.com (unknown [182.195.42.74]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20201224060312epcas5p30a9b993a98e2a90bb163cae9c8bb1fa2~TkcrawTn91936419364epcas5p3l; Thu, 24 Dec 2020 06:03:12 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 23.6C.50652.02F24EF5; Thu, 24 Dec 2020 15:03:12 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20201224055037epcas5p2218eec841b2336f25c9e1fd75fbb5373~TkRssfq462924929249epcas5p2c; Thu, 24 Dec 2020 05:50:37 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20201224055037epsmtrp2aaa50c945d85f84436006814bab4d863~TkRsrtreU0103201032epsmtrp2W; Thu, 24 Dec 2020 05:50:37 +0000 (GMT) X-AuditID: b6c32a4a-6c9ff7000000c5dc-14-5fe42f202537 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id DE.AC.13470.D2C24EF5; Thu, 24 Dec 2020 14:50:37 +0900 (KST) Received: from shradhat02 (unknown [107.122.8.248]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201224055033epsmtip1ad5ccb829235927285b570222c4427d4~TkRo-_zfx0255402554epsmtip1E; Thu, 24 Dec 2020 05:50:33 +0000 (GMT) From: "Shradha Todi" To: "'Bjorn Helgaas'" Cc: , , , , , , "'Sriram Dash'" In-Reply-To: <20201223203403.GA320059@bjorn-Precision-5520> Subject: RE: [PATCH v2] PCI: endpoint: Fix NULL pointer dereference for ->get_features() Date: Thu, 24 Dec 2020 11:20:30 +0530 Message-ID: <096301d6d9b8$b440be00$1cc23a00$@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQHOFva8Guq/R8Jw43oBy2JTBKpOfAKJ6izDqgLzgjA= Content-Language: en-us X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGKsWRmVeSWpSXmKPExsWy7bCmpq6C/pN4g3OfBSyWNGVYvDqzls3i wtMeNovLu+awWZydd5zN4s3vF+wWi7Z+Ybe4sZ7dgcNjzbw1jB4LNpV6bFrVyebRt2UVo8fx G9uZPD5vkgtgi+KySUnNySxLLdK3S+DKmPCym7nglHDF9ntCDYxLBboYOTkkBEwk9k7YzNbF yMUhJLCbUeLnwv9MEM4nRokpK9sYIZxvjBLTL+xghWlZtf8OVMteRonmGR+YIZwXjBIzP/1n BqliE9CReHLlD5gtIqAlcfzgfrBuZoHzjBK7r7KD2JwC1hL3p5xlArGFBaIkZi18CVbPIqAq se/vBzCbV8BSouf7d3YIW1Di5MwnLBBz5CW2v53DDHGRgsTPp8tYIXZZSTw4tpUZokZc4uXR I+wgx0kILOSQ2HTnNyNEg4vEtH1/oWxhiVfHt7BD2FISn9/tZYOw8yWmXngKtIwDyK6QWN5T BxG2lzhwZQ5YmFlAU2L9Ln2IsKzE1FPrmCDW8kn0/n7CBBHnldgxD8ZWlvjydw8LhC0pMe/Y ZdYJjEqzkHw2C8lns5B8MAth2wJGllWMkqkFxbnp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TJxMB5ilOBgVhLhvcT/OF6INyWxsiq1KD++qDQntfgQozQHi5I4 74Wuk/FCAumJJanZqakFqUUwWSYOTqkGpowNflMWHLK6d+iKOZuwjkHqK/+pPD/aTYOvllV9 vDZNdf6u2F8/wh/X7mOd9FiiQFDP4XphTHXE1zC3JN3IXcL+N3ZIWUXeCH3x8PcTn8Mpi1+Z CD0sWdLus/ZlYYyPanmYtFS+oKrI152ZVz+a/NTwk+Wzi9BVPlfmfHHXquDfF/d1hXPet2TM TOMonf8zdveC+Sv0G6eXPbDz/nuyWMY4/mts2P+fvT1m7EEJVjkuxbxB/L9e39jKVKxcWmL+ MenGy6xtq9Lu6fNPurVOrDbSiHmfipjpwX/LKx0/5bHXr/7xWLRx0ZHzgkk7Zu87EaFvzxyR yvB7CcfuCa32Owp0ItdOE26ZuXZjJEuUEktxRqKhFnNRcSIArB4E4RwDAAA= X-CMS-MailID: 20201224055037epcas5p2218eec841b2336f25c9e1fd75fbb5373 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20201223203408epcas5p3909fa2bbaa075ae7253f720c7fca7685 References: <20201223203403.GA320059@bjorn-Precision-5520> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > From: Bjorn Helgaas > Subject: Re: [PATCH v2] PCI: endpoint: Fix NULL pointer dereference for - > >get_features() > > On Fri, Dec 18, 2020 at 09:15:16PM +0530, Shradha Todi wrote: > > 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_feature is not found. > > Can you add a Fixes: tag to identify where this broke to help people decide > where to backport the fix? > Thanks for the review. Sure we will add the Fixes tag and respin this patch. > > Reviewed-by: Pankaj Dubey > > Signed-off-by: Sriram Dash > > Signed-off-by: Shradha Todi > > --- > > v2: > > rebase on v1 > > v1: > > https://protect2.fireeye.com/v1/url?k=6193fa90-3e08c3dd-619271df-0cc47 > > aa8f5ba-a79111ee2c1d1660&q=1&e=a9ee1ef7-2713-4099-8d06- > 738532d78b26&u= > > https%3A%2F%2Flore.kernel.org%2Fpatchwork%2Fpatch%2F1208269%2F > > > > drivers/pci/endpoint/functions/pci-epf-test.c | 13 ++++++++----- > > 1 file changed, 8 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c > > b/drivers/pci/endpoint/functions/pci-epf-test.c > > index 66723d5..f1842e6 100644 > > --- a/drivers/pci/endpoint/functions/pci-epf-test.c > > +++ b/drivers/pci/endpoint/functions/pci-epf-test.c > > @@ -835,13 +835,16 @@ 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; > > - core_init_notifier = epc_features->core_init_notifier; > > - test_reg_bar = pci_epc_get_first_free_bar(epc_features); > > - pci_epf_configure_bar(epf, epc_features); > > + if (!epc_features) { > > + dev_err(&epf->dev, "epc_features not implemented\n"); > > + return -EOPNOTSUPP; > > } > > > > + linkup_notifier = epc_features->linkup_notifier; > > + core_init_notifier = epc_features->core_init_notifier; > > + 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.7.4 > >