Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1776001pxp; Mon, 7 Mar 2022 02:03:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJzeggj3sy01vpgOqRFaqHC8fn39tbWI9Apva7Z6XvSScuqNKYOFoIL2B+1ER+vFFp8c+KTC X-Received: by 2002:a17:902:f686:b0:151:d866:f657 with SMTP id l6-20020a170902f68600b00151d866f657mr8694656plg.112.1646647391754; Mon, 07 Mar 2022 02:03:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646647391; cv=none; d=google.com; s=arc-20160816; b=n7CUpVeqJ81PNUvbqMXIWZX3slIHirsNPn2/qcVI6mdKgY93fDtx9Q8lBQUBnvuz5J uwKXGCDSLKhW2y4XgqaM4PJkW5CZQs6hPn6ha1lOpI0Tglf5JJnkBuVE5Y7pnhF1DNGy X6HeE1+gnbBFAb0diaLzX89/VL1NsYr/S+o19mHTqDvT4a9fnUoXbPaCmn7lyj0Cs9XQ XBV/rqt1cK7QNq8/O/dE+Xy4eK1LC08R+Z7TI0rOAyndS+EYaEmLOW4F33c+L3QbqTu5 A0kAF0xx+GoUzdsJn7g9ggQYLb98BA0d7gCn+YA3QJyCECxYTZfXnKZZPllQq7v910kV iwyQ== 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=jGNTh8Tb8slyiUiELfZeRA8K/sdSkZy2kXrt+AstHNk=; b=pX1QTRXKgsc0308irUZVbAnfyY48+h4Vp8C4JkgPfJwLhm9CotQjqSYTI2RtofHGhN 7sHevjfcYE6FUpWonmjdDQYkbO8LX8MVYWEyPA9X2stuolaJafoC2FKH7yvGdU+5/xjX A8jREY8cTHZihJfz/X3MbNL9FqfYdW3c/N4DRFMLDw81cwq5sqLLv+y3NE4R8TO7Sp9u v0/HArlzDie2wmYIBj3JcET861qpyWUoEM8PORdyCeN6TIz73k2hCTvfKb9RtApQ05Zy uHpvPXTPX0GW08wfDgUCD6gotsuxJ2HWYx4iGGubppPxg55Vbc0ob9CAWh8POYumul1x W5mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hlDYGFNm; 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 d190-20020a6368c7000000b00380494b840fsi2528870pgc.101.2022.03.07.02.02.57; Mon, 07 Mar 2022 02:03:11 -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=hlDYGFNm; 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 S236957AbiCGJ1Q (ORCPT + 99 others); Mon, 7 Mar 2022 04:27:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237329AbiCGJXo (ORCPT ); Mon, 7 Mar 2022 04:23:44 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C166C44760; Mon, 7 Mar 2022 01:22:41 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 564FA60F63; Mon, 7 Mar 2022 09:22:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 630FEC340E9; Mon, 7 Mar 2022 09:22:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646644960; bh=H4TVj+cf/uNrpTzIJj6dLxFemyB75Dl783yOAYEYQhQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hlDYGFNmZsiPqoWUXJ3QDT9Fl9IFgc4F8RO+P/CaeoA+5s8iGQbaWRevR/ShHvu7U oUpixdKCyCw9Ve2sKNNrc1NqYppIOIZQ+W/OjbVEuRl1hVYeublyzAg+GZ0O8W7ZBy 7Y9ITU2LpGoBCNPuKhG0F9vtPzMmkphWC+DMs9q0= 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.14 36/42] net: chelsio: cxgb3: check the return value of pci_find_capability() Date: Mon, 7 Mar 2022 10:19:10 +0100 Message-Id: <20220307091637.203299930@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091636.146155347@linuxfoundation.org> References: <20220307091636.146155347@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 a89721fad633..29220141e4e4 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