Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5072595pxb; Mon, 15 Feb 2021 08:47:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJzERLdjlSWnJWrq5NN9w+t3/PG3aAfYnm4fv/SXZhfcONsQYQj3qd/IOucwL/P2mhkeC9Pr X-Received: by 2002:a05:6402:430c:: with SMTP id m12mr17110147edc.299.1613407659558; Mon, 15 Feb 2021 08:47:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613407659; cv=none; d=google.com; s=arc-20160816; b=b47foCjXoqw5f3rgKi5qdtdxHhQf2Ps6fx9ftklgqYSICaVi7R8Zf5BJ0wO5L2PLgr JmTX61A1zv6edGWgKuzpQgngxQgLAAU1Ju4Eb3l0viq5EVgILFrjhP0dVEUsbwtyUWsz R69q4nG+8W+pUVMn4GsvI7RPLPIp9qrjDdVxSVva5sXiMgmcqHp/KACCYcY+gxnYhS2H vTx1/QYAemPSqOdSZ9+RFuuY6TLfObSVyP2jynzbiqes55Cuu9fgKryF0AUyLuioEw5u M9VQxpyLHfLZkAsbK14LQNgIWkh8YB6MSUYxq973Spr9H4jTI4jgbO8wb6DjiHCKZIUJ i4wg== 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=fvKrJ2QA4BGjxJgD4bo1FxCfgZLShjF57cQ2NIjztzU=; b=Pzcj4SIUYNa741WDrxLrbmQH0KOkmRVvspDY6zHzk+ifqtUO5lPSsDiKfibdzqp2Wb GsUyRaPkC5uarhU2sGwOiuaKz37/OGOzOQ/HnLLeZDASgZ/g3jUMBPf7OwEFxRiNsVmP NwRGgr+UPNYTKjUDo8Rf9zAzDruHSdfjZfqEpH8BDJVsX0e2ntWC12i0UO2NBHS6QA5c a5H3iTn8SVFdLTiWW0txdhZ6mOYxrdGbAIlkgldNXewn1lkOne5inadjp867PVF3Stb0 7hJxg4v4PxqzEnc3F6PAdrAX4Pzoirfmak44ByENNZ0Ttvi9Xd8tHaS8Li1scCVW9Rx+ SxKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FvS2PmX0; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g8si1423218edr.439.2021.02.15.08.47.16; Mon, 15 Feb 2021 08:47:39 -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=@linuxfoundation.org header.s=korg header.b=FvS2PmX0; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230418AbhBOQoA (ORCPT + 99 others); Mon, 15 Feb 2021 11:44:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:50014 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231548AbhBOPh7 (ORCPT ); Mon, 15 Feb 2021 10:37:59 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A8D6B64EA0; Mon, 15 Feb 2021 15:33:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1613403223; bh=grc1k0mbQ9jRudH5zA0+n9VImf0+UaRZieI9KyOEOVY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FvS2PmX048zmbrcU5CLlR4W27PeJbSGRpD+GR79ns/v75qVwqfeD3JT1r0uYAhhCv wTfYEsjVx80YEVPwcHiMpt8AzPWML26I+SO1mgVUrTNHOxkqYZrmj9AwbpzIPz0knm xlHzohDYvN6tTadTAAEcb5a9H3SQcq2RRbBHaEM0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yufeng Mo , Huazhong Tan , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 073/104] net: hns3: add a check for queue_id in hclge_reset_vf_queue() Date: Mon, 15 Feb 2021 16:27:26 +0100 Message-Id: <20210215152721.811226958@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210215152719.459796636@linuxfoundation.org> References: <20210215152719.459796636@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yufeng Mo [ Upstream commit 67a69f84cab60484f02eb8cbc7a76edffbb28a25 ] The queue_id is received from vf, if use it directly, an out-of-bound issue may be caused, so add a check for this queue_id before using it in hclge_reset_vf_queue(). Fixes: 1a426f8b40fc ("net: hns3: fix the VF queue reset flow error") Signed-off-by: Yufeng Mo Signed-off-by: Huazhong Tan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 4321132a4f630..c40820baf48a6 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -9404,12 +9404,19 @@ int hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id) void hclge_reset_vf_queue(struct hclge_vport *vport, u16 queue_id) { + struct hnae3_handle *handle = &vport->nic; struct hclge_dev *hdev = vport->back; int reset_try_times = 0; int reset_status; u16 queue_gid; int ret; + if (queue_id >= handle->kinfo.num_tqps) { + dev_warn(&hdev->pdev->dev, "Invalid vf queue id(%u)\n", + queue_id); + return; + } + queue_gid = hclge_covert_handle_qid_global(&vport->nic, queue_id); ret = hclge_send_reset_tqp_cmd(hdev, queue_gid, true); -- 2.27.0