Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3517485pxf; Mon, 15 Mar 2021 11:18:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3KovX3Tr6FUS4BXLHngwW9CNzHJvmpWTgeEDdU6or1ZPh4ovJVB0Udvzchdzn0Vx2lMfe X-Received: by 2002:a05:6402:17d5:: with SMTP id s21mr31452869edy.65.1615832294729; Mon, 15 Mar 2021 11:18:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832294; cv=none; d=google.com; s=arc-20160816; b=J0e7jld8Z1evb1Mg1igvPIOxJzqdESK8PHJNIPnNYWMTMsMqVorhwgGHHlQ+sRYghp QAq0KBMH+GEU7cVjIEWO0mkK9bwQyt8aJtCsUqOTRMA6OTR5dJK6M3H/OgUNt/nNBzbN xnblNoRN1lEz3xUHiKKaf0qm5w1v7WKMG4+piBAHisABDx9pK2WKp8pPVV66j40Q6ULT htk2tu4QBy4oPlyTgLomY9x1kTdpzUCuDrxWyzSxbylpmI7TyE4xh3AoIeX7R8g+e+LU 0qa/793PzL9b2G+KYk7xZq0kDEsdXc2awkwLFELi1vZtoMZDAFASJMO4EkcPgx5a7P1J Ce0g== 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=I0BmjQjybALcbWXpdE9ZMyim9aCaOMEPoyB5w4CYM4OzOyJo83Mze+tMGqPs6uuTAH LTFBz28HJ9DEkckRiENo7HoxRnUzWJA6zqx//U1pkKyys0xKzhssu0Ah+NPpzhDfvx2m ii4wZg28xmFnBZrH3Um6riv+6koiJOWoGza+XI7I6fkbUwNIGAr3vc5zo0bMCaMW9naj AsiWkRRi2JTSowtmzMhIIpUlr18gNV4jocQYNbfotkrGlp1FyVqT3rgfF74zQ8ZznGd0 wEkwdVXfjn6uQDiH35RfaTCht4bKku4slCAyvjKhh0xFhyPI1oqeX7PVZybiBhJnQD2x 66vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=b+6t7cPC; 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 d22si12132455ejk.139.2021.03.15.11.17.52; Mon, 15 Mar 2021 11:18:14 -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=b+6t7cPC; 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 S236824AbhCOOPp (ORCPT + 99 others); Mon, 15 Mar 2021 10:15:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:37522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232470AbhCON65 (ORCPT ); Mon, 15 Mar 2021 09:58:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1EF3F64F83; Mon, 15 Mar 2021 13:58:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816718; bh=Vr0sgJqWyvNZnVFR/n03t2Gv7d6qsk5EVb5smonF9Oo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b+6t7cPCopqaMcOLPPwUPtkcdjGxzdae5NyFr0PRMfkSQVO5Y+iVNMPBFDLs8rFma oqv5n4+WXFBL4ffClO7UVICr0HIai4xl8N9Bys7heztiocGwqE9HYsDsp3eMnOkp7H pksq9LbxMiB0XxVsEyNuuH6Dk8f2P6al933ZuCdM= 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.11 083/306] ethtool: fix the check logic of at least one channel for RX/TX Date: Mon, 15 Mar 2021 14:52:26 +0100 Message-Id: <20210315135510.455944368@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@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; }