From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-eopbgr730127.outbound.protection.outlook.com ([40.107.73.127]:59536 "EHLO NAM05-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728479AbeIQIZi (ORCPT ); Mon, 17 Sep 2018 04:25:38 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Yunsheng Lin , Peng Li , Salil Mehta , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL 4.18 010/136] net: hns3: Fix get_vector ops in hclgevf_main module Date: Mon, 17 Sep 2018 03:00:17 +0000 Message-ID: <20180917030006.245495-10-alexander.levin@microsoft.com> References: <20180917030006.245495-1-alexander.levin@microsoft.com> In-Reply-To: <20180917030006.245495-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Yunsheng Lin [ Upstream commit 03718db97bfb57535f3aa8110f0cbe0c616a67c0 ] The hclgevf_free_vector function expects the caller to pass the vector_id to it, and hclgevf_put_vector pass vector to it now, which will cause vector allocation problem. This patch fixes it by converting vector into vector_id before calling hclgevf_free_vector. Fixes: e2cb1dec9779 ("net: hns3: Add HNS3 VF HCL(Hardware Compatibility Lay= er) Support") Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Signed-off-by: Salil Mehta Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/dr= ivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index a17872aab168..12aa1f1b99ef 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -648,8 +648,17 @@ static int hclgevf_unmap_ring_from_vector( static int hclgevf_put_vector(struct hnae3_handle *handle, int vector) { struct hclgevf_dev *hdev =3D hclgevf_ae_get_hdev(handle); + int vector_id; =20 - hclgevf_free_vector(hdev, vector); + vector_id =3D hclgevf_get_vector_index(hdev, vector); + if (vector_id < 0) { + dev_err(&handle->pdev->dev, + "hclgevf_put_vector get vector index fail. ret =3D%d\n", + vector_id); + return vector_id; + } + + hclgevf_free_vector(hdev, vector_id); =20 return 0; } --=20 2.17.1