Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3514269pxf; Mon, 15 Mar 2021 11:13:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxI1jKvpSFucEBvCT3nMTUUtuzzjLM1qU8lMyCfAmjwnJbGqMuEsSUxjKh5jDItxkaj0SQI X-Received: by 2002:a17:906:8546:: with SMTP id h6mr24616942ejy.23.1615832024875; Mon, 15 Mar 2021 11:13:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832024; cv=none; d=google.com; s=arc-20160816; b=u9d6AoEjHtxGVuGBVqfXlbVQCGQQqX76GlAQBE9g3TdedAPp51+KK/k6VqkS0xm/SM t4ide85xp2iJMagPkgXj2P0r+JMMU8qdRV9RZjhvLLEUtW1ZnSpUVXPjBejOurCN5CnO PzNxzn1Z7vI9AKfhm6A1bY5DNWZrqrkXRE23uVPq8W2iqCMIMJQd+na+AHGtkNOdQHwr o+RVr3FyRdfJzVuiixQ6RlI+e8xvcLZUszsJEySnWTJqJe7A38CSt0IR6sZYep5m+gm/ rN43AxCbARv0h0T+Fdcc9/Cm/A21vPl4Pfm1zMAgAsHos452X/Ve89mCQR9qeyKOgyem fg1Q== 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=zsXdfCu/j/QFdn/LupYDqSKPkQtLrnhMIpj6W6ljER0=; b=lVK9XCG01Kkv3Bld9MJb5VrPLsXtVYt4acDkntz1YWdku+MOrAAGLoWowfWuqpEze+ fge9Rs80FYNyGWemngPfBZipsNf8UuY5/XXXa1W6nfEMmPYepwOkT/rVMrUZviCnWoF5 X8cosTr6NXlkT5LTRUiX7BfSt4HZY99oqyzZqb0486cH3o9HX6NJSOW7nfHdiymgKMUD zRJEnf1dqNwxWsqf02DjjRN9cC9aijFQb0XM10WD5TznvyGouczoUevX2bcM3DLnoxYA YE50j3cwttw6O14SN8tPmRuprOcJArxpchSANtRAMqoNEbr6pwzxQUgCJIylTZVHm3am bpMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PSwy3xkE; 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 w25si11622190ejv.100.2021.03.15.11.13.22; Mon, 15 Mar 2021 11:13:44 -0700 (PDT) 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=PSwy3xkE; 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 S236297AbhCOOMp (ORCPT + 99 others); Mon, 15 Mar 2021 10:12:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:35186 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232406AbhCON6x (ORCPT ); Mon, 15 Mar 2021 09:58:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 13E5B64EEE; Mon, 15 Mar 2021 13:58:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816710; bh=Vr0sgJqWyvNZnVFR/n03t2Gv7d6qsk5EVb5smonF9Oo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PSwy3xkEViYcJeCPd6CxusuzSiD3lU1IJW4b4xWumMw9s9a0raiaL0vY90NqDwb7G ivCIeu9Hc8cuGC3dUxba9FC/HPIU6b9TZDYsrqQA7BB8WmaYxWT/4YeoMXcLh7sqa1 iaFVmDqJQQPudMGFxyn2u+NpZ+d0rPM3DxPAE7iM= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yinjun Zhang , Simon Horman , Louis Peens , Jakub Kicinski Subject: [PATCH 5.10 069/290] ethtool: fix the check logic of at least one channel for RX/TX Date: Mon, 15 Mar 2021 14:52:42 +0100 Message-Id: <20210315135544.237279519@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@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: Greg Kroah-Hartman From: Yinjun Zhang commit a4fc088ad4ff4a99d01978aa41065132b574b4b2 upstream. The command "ethtool -L combined 0" may clean the RX/TX channel count and skip the error path, since the attrs tb[ETHTOOL_A_CHANNELS_RX_COUNT] and tb[ETHTOOL_A_CHANNELS_TX_COUNT] are NULL in this case when recent ethtool is used. Tested using ethtool v5.10. Fixes: 7be92514b99c ("ethtool: check if there is at least one channel for TX/RX in the core") Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman Signed-off-by: Louis Peens Link: https://lore.kernel.org/r/20210225125102.23989-1-simon.horman@netronome.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/ethtool/channels.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) --- a/net/ethtool/channels.c +++ b/net/ethtool/channels.c @@ -116,10 +116,9 @@ int ethnl_set_channels(struct sk_buff *s struct ethtool_channels channels = {}; struct ethnl_req_info req_info = {}; struct nlattr **tb = info->attrs; - const struct nlattr *err_attr; + u32 err_attr, max_rx_in_use = 0; const struct ethtool_ops *ops; struct net_device *dev; - u32 max_rx_in_use = 0; int ret; ret = ethnl_parse_header_dev_get(&req_info, @@ -157,34 +156,35 @@ int ethnl_set_channels(struct sk_buff *s /* ensure new channel counts are within limits */ if (channels.rx_count > channels.max_rx) - err_attr = tb[ETHTOOL_A_CHANNELS_RX_COUNT]; + err_attr = ETHTOOL_A_CHANNELS_RX_COUNT; else if (channels.tx_count > channels.max_tx) - err_attr = tb[ETHTOOL_A_CHANNELS_TX_COUNT]; + err_attr = ETHTOOL_A_CHANNELS_TX_COUNT; else if (channels.other_count > channels.max_other) - err_attr = tb[ETHTOOL_A_CHANNELS_OTHER_COUNT]; + err_attr = ETHTOOL_A_CHANNELS_OTHER_COUNT; else if (channels.combined_count > channels.max_combined) - err_attr = tb[ETHTOOL_A_CHANNELS_COMBINED_COUNT]; + err_attr = ETHTOOL_A_CHANNELS_COMBINED_COUNT; else - err_attr = NULL; + err_attr = 0; if (err_attr) { ret = -EINVAL; - NL_SET_ERR_MSG_ATTR(info->extack, err_attr, + NL_SET_ERR_MSG_ATTR(info->extack, tb[err_attr], "requested channel count exceeds maximum"); goto out_ops; } /* ensure there is at least one RX and one TX channel */ if (!channels.combined_count && !channels.rx_count) - err_attr = tb[ETHTOOL_A_CHANNELS_RX_COUNT]; + err_attr = ETHTOOL_A_CHANNELS_RX_COUNT; else if (!channels.combined_count && !channels.tx_count) - err_attr = tb[ETHTOOL_A_CHANNELS_TX_COUNT]; + err_attr = ETHTOOL_A_CHANNELS_TX_COUNT; else - err_attr = NULL; + err_attr = 0; if (err_attr) { if (mod_combined) - err_attr = tb[ETHTOOL_A_CHANNELS_COMBINED_COUNT]; + err_attr = ETHTOOL_A_CHANNELS_COMBINED_COUNT; ret = -EINVAL; - NL_SET_ERR_MSG_ATTR(info->extack, err_attr, "requested channel counts would result in no RX or TX channel being configured"); + NL_SET_ERR_MSG_ATTR(info->extack, tb[err_attr], + "requested channel counts would result in no RX or TX channel being configured"); goto out_ops; }