Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38EFFC61DA4 for ; Wed, 15 Mar 2023 19:49:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232927AbjCOTtM (ORCPT ); Wed, 15 Mar 2023 15:49:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232171AbjCOTtD (ORCPT ); Wed, 15 Mar 2023 15:49:03 -0400 Received: from forwardcorp1b.mail.yandex.net (forwardcorp1b.mail.yandex.net [178.154.239.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26EBB1BAF5; Wed, 15 Mar 2023 12:48:32 -0700 (PDT) Received: from mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:2619:0:640:e777:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTP id 81B665FF97; Wed, 15 Mar 2023 22:48:26 +0300 (MSK) Received: from d-tatianin-nix.HomeLAN (unknown [2a02:6b8:b081:b711::1:2a]) by mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id MmpZl50hv8c0-V1mgUtDL; Wed, 15 Mar 2023 22:48:25 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1678909705; bh=KYvNM7ml1IcN3ZNSKnTy48XecqCZr9+I5Ds2ibkGhKw=; h=Message-Id:Date:Cc:Subject:To:From; b=pdPX0IVlA1H44yMCMnFcRkg3FaxYcbPuFaqRgjAfRt73SUszrfvCMPm4lo4g6eb4l 4LfXMTjbGGRXOVcc1bMYt1UHynKY3gxoNqT9j9639XdHgWNjaJLPvBquJZ9lejvkd7 vHE1af5ZgHomRZ4vIkzNqO9movKtBkT3NSJGhTIs= Authentication-Results: mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Daniil Tatianin To: Ariel Elior Cc: Daniil Tatianin , Manish Chopra , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Yuval Mintz , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] qed/qed_sriov: avoid a possible NULL deref in configure_min_tx_rate Date: Wed, 15 Mar 2023 22:48:09 +0300 Message-Id: <20230315194809.579756-1-d-tatianin@yandex-team.ru> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We have to make sure that the info returned by qed_iov_get_vf_info is valid before using it. Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool. Fixes: 733def6a04bf ("qed*: IOV link control") Signed-off-by: Daniil Tatianin --- drivers/net/ethernet/qlogic/qed/qed_sriov.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/qlogic/qed/qed_sriov.c b/drivers/net/ethernet/qlogic/qed/qed_sriov.c index 2bf18748581d..cd43f1b23eb1 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_sriov.c +++ b/drivers/net/ethernet/qlogic/qed/qed_sriov.c @@ -4404,6 +4404,9 @@ qed_iov_configure_min_tx_rate(struct qed_dev *cdev, int vfid, u32 rate) } vf = qed_iov_get_vf_info(QED_LEADING_HWFN(cdev), (u16)vfid, true); + if (!vf) + return -EINVAL; + vport_id = vf->vport_id; return qed_configure_vport_wfq(cdev, vport_id, rate); -- 2.25.1