]> www.infradead.org Git - users/hch/misc.git/commitdiff
net: ethtool: remove the duplicated handling from ethtool_get_rxrings
authorBreno Leitao <leitao@debian.org>
Wed, 17 Sep 2025 09:58:10 +0000 (02:58 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 18 Sep 2025 14:07:37 +0000 (07:07 -0700)
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@debian.org>
Link: https://patch.msgid.link/20250917-gxrings-v4-3-dae520e2e1cb@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ethtool/ioctl.c

index 4214ab33c3c811836ae66a3a3a8b3295226b1be9..a0f3de76cea03391fc2126a82bde04ec37524e43 100644 (file)
@@ -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;