Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1432560iob; Thu, 5 May 2022 00:42:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyy7XHYKS2rK6lEwmiorFbHMCxTGSGRkF31agqU7nTe8HqCL5+hp9Ye7aQUzqJYjVQFEt3c X-Received: by 2002:a17:90b:1b07:b0:1dc:5ec5:56b0 with SMTP id nu7-20020a17090b1b0700b001dc5ec556b0mr4498682pjb.165.1651736522728; Thu, 05 May 2022 00:42:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651736522; cv=none; d=google.com; s=arc-20160816; b=BHHUvoFCLKjYRK/8Patmq/83W95AXzFcKa5Qa+FO8+R2nVd99enD7Lz34ZKpu2KRtq 9gPuxTV2pjyHV+h12jlUatIn5HD6nV7Sl0d7ELNqoY9lzimlpyA5uto6a6W82BXdC75+ e6AjzKhC0vQO2/MDJHl5V1ZZWPTn8lj8G5O0oS+gtBtct1MeDPUnj3pjI+RF8ddFOTjf NAHrqFaw3JgpOm7NcHUcFxUIdforwK5Z3KS8EjLk/pZQwKv+rbj5HQlrWVy2SAM8AI6i AEcpCR2jcmXowNfAl+z48V51tE4pfiUQV3zX2ZAIJYrLwdNQV+Gw6vnm5gi8Os0lKFPH EWTg== 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=Ac+gqyvluFSTaOfSYQA84lxttpEPxvbIvCChBLDb2ms=; b=ylNx2rvzcj6sOD+RqIDmM1gMZ3Bv+xnUFxbBb/ZfzIUWyhE8kb1qUhS1cPeJWy9sRB p40U7xtg+39XeE4wz1o9vwo7A1vryphdUbW4hENx0lsOb1sSpGIMGzXaSuzgAAgOn16d fCffsC5euPMDRm2hLUegNzZodglYl7b4BI8bmvaUxSDgq/OXFq1C4V0Adhw8Of59gkQd yIBVdMgZKU7DVKw03BUDYDBOSFSgUyuo6XJTgy1D79kanDUBc9DPvog5k40iMtvCp9rw 5JmlCBGYl50G6qg1T+WY6GZk7rfVylXQZ4bLqXHgZVxV/9UY3LEs1mqRtc3+Hcy4XaXx 8Ltg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1z9PNxSH; 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 p9-20020a17090a748900b001dc1a41038fsi1023265pjk.88.2022.05.05.00.41.47; Thu, 05 May 2022 00:42:02 -0700 (PDT) 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=1z9PNxSH; 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 S1356486AbiEDR0E (ORCPT + 99 others); Wed, 4 May 2022 13:26:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354719AbiEDRFU (ORCPT ); Wed, 4 May 2022 13:05:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A6BB5133A; Wed, 4 May 2022 09:54:15 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 864B0B8278E; Wed, 4 May 2022 16:54:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21897C385A4; Wed, 4 May 2022 16:54:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683253; bh=cQKzmDC6nWwnIM5+CUyyN+OnLwgvDDKKjIundLrhefs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1z9PNxSHs48N/RQsVC7yDiQ85GSwCTgC1ySt07ZIDxZDB31GLxdFmefdX3IVKy6ha 6KUeRl+3iN4XoW1UK1wUh+5J71HA9mA3IKCJXh62zgIPV9rQw6Ze2ybpcGfTA96Y8/ 868haQD6JCOb12BkUnntuVcogJX2uweUoflQPygg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jian Shen , Guangbin Huang , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 096/177] net: hns3: add return value for mailbox handling in PF Date: Wed, 4 May 2022 18:44:49 +0200 Message-Id: <20220504153101.716777921@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@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.7 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: Jian Shen [ Upstream commit c59d606296842409a6e5a4828235b0bd46b12bc4 ] Currently, there are some querying mailboxes sent from VF to PF, and VF will wait the PF's handling result. For mailbox HCLGE_MBX_GET_QID_IN_PF and HCLGE_MBX_GET_RSS_KEY, it may fail when the input parameter is invalid, but the prototype of their handler function is void. In this case, PF always return success to VF, which may cause the VF get incorrect result. Fixes it by adding return value for these function. Fixes: 63b1279d9905 ("net: hns3: check queue id range before using") Fixes: 532cfc0df1e4 ("net: hns3: add a check for index in hclge_get_rss_key()") Signed-off-by: Jian Shen Signed-off-by: Guangbin Huang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../hisilicon/hns3/hns3pf/hclge_mbx.c | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c index c256305a2212..4a5b11b6fed3 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c @@ -593,9 +593,9 @@ static int hclge_set_vf_mtu(struct hclge_vport *vport, return hclge_set_vport_mtu(vport, mtu); } -static void hclge_get_queue_id_in_pf(struct hclge_vport *vport, - struct hclge_mbx_vf_to_pf_cmd *mbx_req, - struct hclge_respond_to_vf_msg *resp_msg) +static int hclge_get_queue_id_in_pf(struct hclge_vport *vport, + struct hclge_mbx_vf_to_pf_cmd *mbx_req, + struct hclge_respond_to_vf_msg *resp_msg) { struct hnae3_handle *handle = &vport->nic; struct hclge_dev *hdev = vport->back; @@ -605,17 +605,18 @@ static void hclge_get_queue_id_in_pf(struct hclge_vport *vport, if (queue_id >= handle->kinfo.num_tqps) { dev_err(&hdev->pdev->dev, "Invalid queue id(%u) from VF %u\n", queue_id, mbx_req->mbx_src_vfid); - return; + return -EINVAL; } qid_in_pf = hclge_covert_handle_qid_global(&vport->nic, queue_id); memcpy(resp_msg->data, &qid_in_pf, sizeof(qid_in_pf)); resp_msg->len = sizeof(qid_in_pf); + return 0; } -static void hclge_get_rss_key(struct hclge_vport *vport, - struct hclge_mbx_vf_to_pf_cmd *mbx_req, - struct hclge_respond_to_vf_msg *resp_msg) +static int hclge_get_rss_key(struct hclge_vport *vport, + struct hclge_mbx_vf_to_pf_cmd *mbx_req, + struct hclge_respond_to_vf_msg *resp_msg) { #define HCLGE_RSS_MBX_RESP_LEN 8 struct hclge_dev *hdev = vport->back; @@ -631,13 +632,14 @@ static void hclge_get_rss_key(struct hclge_vport *vport, dev_warn(&hdev->pdev->dev, "failed to get the rss hash key, the index(%u) invalid !\n", index); - return; + return -EINVAL; } memcpy(resp_msg->data, &hdev->vport[0].rss_hash_key[index * HCLGE_RSS_MBX_RESP_LEN], HCLGE_RSS_MBX_RESP_LEN); resp_msg->len = HCLGE_RSS_MBX_RESP_LEN; + return 0; } static void hclge_link_fail_parse(struct hclge_dev *hdev, u8 link_fail_code) @@ -812,10 +814,10 @@ void hclge_mbx_handler(struct hclge_dev *hdev) "VF fail(%d) to set mtu\n", ret); break; case HCLGE_MBX_GET_QID_IN_PF: - hclge_get_queue_id_in_pf(vport, req, &resp_msg); + ret = hclge_get_queue_id_in_pf(vport, req, &resp_msg); break; case HCLGE_MBX_GET_RSS_KEY: - hclge_get_rss_key(vport, req, &resp_msg); + ret = hclge_get_rss_key(vport, req, &resp_msg); break; case HCLGE_MBX_GET_LINK_MODE: hclge_get_link_mode(vport, req); -- 2.35.1