Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1777845pxp; Mon, 7 Mar 2022 02:05:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJyeeMgpCsFqvR7v6y1u6a57yX7zKhvRm4LvoAZFZfv3ckpbf/ALJFP83Zv/mIlD6AnBDoQ+ X-Received: by 2002:a17:907:96ab:b0:6d7:1720:15d6 with SMTP id hd43-20020a17090796ab00b006d7172015d6mr8538339ejc.322.1646647529531; Mon, 07 Mar 2022 02:05:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646647529; cv=none; d=google.com; s=arc-20160816; b=HtDY9ktrOTMG17LvZVCBCfICINpMkAEaGwgl3Drkm3JHU2VBXEuqCSAr9BGg/yLAJn qKSnXNZRJeH8uwR6jIq4oAmXMPJHRXcpt5OfAK1YG6ykk82CuXcRjAQc2POI9bEFuAY1 O2gEJovdi6FnkpeHErw/l01286TOj1HTKB5bDm4OOe5klfkQN5Aok7qBt332UztD/YRW GRcgy+iwmUfZkcszd2yrxmVd9pWMF7mvUHP6x9iGmcbrqATWKj3hx9ZNseF/9auHZQKn eaTUh94r+7U5ydtxaB/m6EmAtvoZxApsYciJlW+q2CgGVJvl5BzvfWui5Uc/MBO6T1Jl 2Etw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bFc0no9NMVtDw8WJkgAUYihOPA+wUpevCj7QMXEQj1s=; b=gSTa8MCNat4g3zTyFNNSK3fPVNHolBRP6Xhy62TThMP/DbTkPqpnRvE0N83gyHvMs0 E/we1J4AFg6g/CUAhxXrpI0JOqNXeYk+PlLjz1qE4sGVK9TFpvDigCV2qd74mBNULNNT FyCkfM+iBOKdIFawp+qEhL95Je1yb+lZmrgFWCl5YNy9uNBxc5R1jQZFh6cW1vjcoZEa rt6L6IM6iLcw7Cs+DdN/prPnofkMuQYsVkBdTaH4HBtQvhLgQzHcfmdhzyAYnBnGG3Sw 54Ts1fbsgIhtz+vmMpu0kFyt5PsO4U+BCfO0la3mxqvYEMyYfaRygP4hcMcYn9wHQcjk S5Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=J4CfGYdg; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qb42-20020a1709077eaa00b006cd7ca08425si7545673ejc.910.2022.03.07.02.05.06; Mon, 07 Mar 2022 02:05:29 -0800 (PST) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=J4CfGYdg; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237247AbiCGJbF (ORCPT + 99 others); Mon, 7 Mar 2022 04:31:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237464AbiCGJ2I (ORCPT ); Mon, 7 Mar 2022 04:28:08 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D6D65AEEF; Mon, 7 Mar 2022 01:25:27 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1C3EBB810B9; Mon, 7 Mar 2022 09:25:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5472BC36AE2; Mon, 7 Mar 2022 09:25:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646645114; bh=aMwMtXs6moMQebat+KZd1RU03CTYTmj44vWgILym86E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J4CfGYdgT/aKMWNlVBwqoNL+zAmr1U32juLWxskgdmcyXb10oghQeZRZa63OZxh/K RptbMojUxEiiyx/E6l68CtXuN7PA4aLZW3ieJR6H471q+3umZhrzzxir3C/bDZHucU HTZIo9DTIDnpNzMtH3hEUkeCqbi5dswy8gyZsG48= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, TOTE Robot , Jia-Ju Bai , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 43/51] net: chelsio: cxgb3: check the return value of pci_find_capability() Date: Mon, 7 Mar 2022 10:19:18 +0100 Message-Id: <20220307091638.216605772@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091636.988950823@linuxfoundation.org> References: <20220307091636.988950823@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Jia-Ju Bai [ Upstream commit 767b9825ed1765894e569a3d698749d40d83762a ] The function pci_find_capability() in t3_prep_adapter() can fail, so its return value should be checked. Fixes: 4d22de3e6cc4 ("Add support for the latest 1G/10G Chelsio adapter, T3") Reported-by: TOTE Robot Signed-off-by: Jia-Ju Bai Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/chelsio/cxgb3/t3_hw.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c b/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c index 080918af773c..cf563cdd0cb8 100644 --- a/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c +++ b/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c @@ -3677,6 +3677,8 @@ int t3_prep_adapter(struct adapter *adapter, const struct adapter_info *ai, MAC_STATS_ACCUM_SECS : (MAC_STATS_ACCUM_SECS * 10); adapter->params.pci.vpd_cap_addr = pci_find_capability(adapter->pdev, PCI_CAP_ID_VPD); + if (!adapter->params.pci.vpd_cap_addr) + return -ENODEV; ret = get_vpd_params(adapter, &adapter->params.vpd); if (ret < 0) return ret; -- 2.34.1