[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250912-gxrings-v2-3-3c7a60bbeebf@debian.org>
Date: Fri, 12 Sep 2025 08:59:12 -0700
From: Breno Leitao <leitao@...ian.org>
To: Andrew Lunn <andrew@...n.ch>, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>,
kuba@...nel.org, Simon Horman <horms@...nel.org>,
"Michael S. Tsirkin" <mst@...hat.com>, Jason Wang <jasowang@...hat.com>,
Xuan Zhuo <xuanzhuo@...ux.alibaba.com>,
Eugenio Pérez <eperezma@...hat.com>,
Andrew Lunn <andrew+netdev@...n.ch>
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
virtualization@...ts.linux.dev, Breno Leitao <leitao@...ian.org>,
Lei Yang <leiyang@...hat.com>, kernel-team@...a.com
Subject: [PATCH net-next v2 3/7] net: ethtool: remove the duplicated
handling from ethtool_get_rxrings
ethtool_get_rxrings() was a copy of ethtool_get_rxnfc(). Clean the code
that will never be executed for GRXRINGS specifically.
Signed-off-by: Breno Leitao <leitao@...ian.org>
---
net/ethtool/ioctl.c | 33 ++++++++++-----------------------
1 file changed, 10 insertions(+), 23 deletions(-)
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 4214ab33c3c81..a0f3de76cea03 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -1212,52 +1212,39 @@ static noinline_for_stack int ethtool_get_rxrings(struct net_device *dev,
u32 cmd,
void __user *useraddr)
{
- struct ethtool_rxnfc info;
- size_t info_size = sizeof(info);
const struct ethtool_ops *ops = dev->ethtool_ops;
+ struct ethtool_rxnfc info;
+ size_t info_size;
int ret;
- void *rule_buf = NULL;
if (!ops->get_rxnfc)
return -EOPNOTSUPP;
+ info_size = sizeof(info);
ret = ethtool_rxnfc_copy_struct(cmd, &info, &info_size, useraddr);
if (ret)
return ret;
- if (info.cmd == ETHTOOL_GRXCLSRLALL) {
- if (info.rule_cnt > 0) {
- if (info.rule_cnt <= KMALLOC_MAX_SIZE / sizeof(u32))
- rule_buf = kcalloc(info.rule_cnt, sizeof(u32),
- GFP_USER);
- if (!rule_buf)
- return -ENOMEM;
- }
- }
-
- ret = ops->get_rxnfc(dev, &info, rule_buf);
+ ret = ops->get_rxnfc(dev, &info, NULL);
if (ret < 0)
- goto err_out;
-
- ret = ethtool_rxnfc_copy_to_user(useraddr, &info, info_size, rule_buf);
-err_out:
- kfree(rule_buf);
+ return ret;
- return ret;
+ return ethtool_rxnfc_copy_to_user(useraddr, &info, info_size, NULL);
}
static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev,
u32 cmd, void __user *useraddr)
{
- struct ethtool_rxnfc info;
- size_t info_size = sizeof(info);
const struct ethtool_ops *ops = dev->ethtool_ops;
- int ret;
+ struct ethtool_rxnfc info;
void *rule_buf = NULL;
+ size_t info_size;
+ int ret;
if (!ops->get_rxnfc)
return -EOPNOTSUPP;
+ info_size = sizeof(info);
ret = ethtool_rxnfc_copy_struct(cmd, &info, &info_size, useraddr);
if (ret)
return ret;
--
2.47.3
Powered by blists - more mailing lists