Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5039383pxb; Mon, 15 Feb 2021 08:01:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwCvaEQIfY9n/0DTcEZwXFCwJKhhOJyEzn6KyGCVbG/cFK0D3FJghFP3nueVTQkqCy6GM9x X-Received: by 2002:a17:906:5fc5:: with SMTP id k5mr5625966ejv.207.1613404892253; Mon, 15 Feb 2021 08:01:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613404892; cv=none; d=google.com; s=arc-20160816; b=RjzYLxvgTJShoZH/A4ctMm71fHn87XvKpNi3Rm6/wP5fePeNilQPse9WHTbDMjgtFo +Plzn0yJvfBKOm+xy2+tZQxaBcNglPqkeWkdJymV8dGEVlg4/4vjH9vZmHrXFYEf1gO2 Lj8ShLQmYvLP4qsQfmEYn2sP3nZAXAkinu1t57E+IWqSbGv23BUQLdiM4uKt2fzCQWDw dcflm2Di70rIzO+jf+1gADq4GzGp1U+/2K8319YDumBp0K6O+JkZpcc3tE1ViWGvRJHI r4D0A7zu9+zlN3yFCruC1siYcTY1P1+8WwFhSew58GzD3UO+Y+yJh6L9gw5OUfH2XagR jcbA== 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=zhFIKUlbT9lbt+vbtHiFvhlxHDCbqUPRm1Gw1Mi8YTg=; b=B/8nbE94cKQuxYGt9cNmldWeEpB40RykP+oVDwma89PnAglSpaAKpaQPJcugCwuMfw GImGpyqMHtf/ShYol5s/E9lKUZXJ23ZrHfNEddF8kaYaiOvMrz9+M15QuAUwZsT9AAjc NYbwa7ENUmyVwF7YxtAx/qorcU37EougLb0OYCiqnjUERhmyI+58x2yelIXnHJp/v2UA pjGqkVK17tuLpNvnqH0BjE1HlkceF0rtEAa9fcyVvt7TGx8J8Sk9fZ2MSiW7wDKE/n6n MRhiP4nNeATgjOsbznpqJkT/Kv6UQYNWrSBLR5eBUsKqDdEZi2K3veebkfLYqp6YNyF6 opRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iGTmO6gb; 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 q3si8172867ejb.681.2021.02.15.08.01.07; Mon, 15 Feb 2021 08:01:32 -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=iGTmO6gb; 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 S232448AbhBOP6R (ORCPT + 99 others); Mon, 15 Feb 2021 10:58:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:46916 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231136AbhBOPbn (ORCPT ); Mon, 15 Feb 2021 10:31:43 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id CB6B164E34; Mon, 15 Feb 2021 15:29:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1613402972; bh=SKFQENu7INq7P849sQ2+kBobGSIxyjI5eJfGYtCYQqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iGTmO6gbij3JkkiZYNa1E1PVROIIYEiAIAFob6k+vupgrCwofeUd/2ikonPRSMv9B iCWIiKqiyADtFXq/vP4g5FcPAIGe/YNb6MckG0az+hi4uMVw+0GPCcI2SNqGKe1H6e xuVmRQveGxC5alTermeW2Zwzx1X8W+77D2Y8f4Jc= 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.4 39/60] net: hns3: add a check for queue_id in hclge_reset_vf_queue() Date: Mon, 15 Feb 2021 16:27:27 +0100 Message-Id: <20210215152716.617536072@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210215152715.401453874@linuxfoundation.org> References: <20210215152715.401453874@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 6887b7fda6e07..08040cafc06bc 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -8563,12 +8563,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