ethtool: use ethnl_parse_header_dev_put()
authorEric Dumazet <edumazet@google.com>
Tue, 14 Dec 2021 08:42:30 +0000 (00:42 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 15 Dec 2021 10:27:47 +0000 (10:27 +0000)
It seems I missed that most ethnl_parse_header_dev_get() callers
declare an on-stack struct ethnl_req_info, and that they simply call
dev_put(req_info.dev) when about to return.

Add ethnl_parse_header_dev_put() helper to properly untrack
reference taken by ethnl_parse_header_dev_get().

Fixes: e4b8954074f6 ("netlink: add net device refcount tracker to struct ethnl_req_info")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
16 files changed:
net/ethtool/cabletest.c
net/ethtool/channels.c
net/ethtool/coalesce.c
net/ethtool/debug.c
net/ethtool/eee.c
net/ethtool/features.c
net/ethtool/fec.c
net/ethtool/linkinfo.c
net/ethtool/linkmodes.c
net/ethtool/module.c
net/ethtool/netlink.h
net/ethtool/pause.c
net/ethtool/privflags.c
net/ethtool/rings.c
net/ethtool/tunnels.c
net/ethtool/wol.c

index 63560bbb7d1f0b4a4ca76b2986e896d922bd7745..920aac02fe390edcc512ca1beaafd874a2fdb937 100644 (file)
@@ -96,7 +96,7 @@ int ethnl_act_cable_test(struct sk_buff *skb, struct genl_info *info)
 out_rtnl:
        rtnl_unlock();
 out_dev_put:
-       dev_put(dev);
+       ethnl_parse_header_dev_put(&req_info);
        return ret;
 }
 
@@ -353,7 +353,7 @@ int ethnl_act_cable_test_tdr(struct sk_buff *skb, struct genl_info *info)
 out_rtnl:
        rtnl_unlock();
 out_dev_put:
-       dev_put(dev);
+       ethnl_parse_header_dev_put(&req_info);
        return ret;
 }
  
index 6a070dc8e4b0dba90656d92f742320200c6bdfe3..403158862011588ded7a448b13e39702551b2df4 100644 (file)
@@ -219,6 +219,6 @@ out_ops:
 out_rtnl:
        rtnl_unlock();
 out_dev:
-       dev_put(dev);
+       ethnl_parse_header_dev_put(&req_info);
        return ret;
 }
index 46776ea42a92e1daf2982f06287b2227d9b045f7..487bdf345541ad1966702e600335a015edd9feda 100644 (file)
@@ -336,6 +336,6 @@ out_ops:
 out_rtnl:
        rtnl_unlock();
 out_dev:
-       dev_put(dev);
+       ethnl_parse_header_dev_put(&req_info);
        return ret;
 }
index f99912d7957ead331a772dbdd70a64f0e374b7ae..d73888c7d19ca71eb384cf89aa2ffc786c6a3f30 100644 (file)
@@ -123,6 +123,6 @@ out_ops:
 out_rtnl:
        rtnl_unlock();
 out_dev:
-       dev_put(dev);
+       ethnl_parse_header_dev_put(&req_info);
        return ret;
 }
index e10bfcc0785317f3b19e2ee2d0513c60a495151b..45c42b2d5f1785c4ff3492b6d78e0c826c583ba9 100644 (file)
@@ -185,6 +185,6 @@ out_ops:
 out_rtnl:
        rtnl_unlock();
 out_dev:
-       dev_put(dev);
+       ethnl_parse_header_dev_put(&req_info);
        return ret;
 }
index 2e7331b23996aa7b09b2eb5d4d34b9b407c98b74..55d449a2d3fcb35d0b3952a8184f3079e3403cde 100644 (file)
@@ -283,6 +283,6 @@ int ethnl_set_features(struct sk_buff *skb, struct genl_info *info)
 
 out_rtnl:
        rtnl_unlock();
-       dev_put(dev);
+       ethnl_parse_header_dev_put(&req_info);
        return ret;
 }
index 8738dafd5417227724cba9e36dd3dff4dd44d636..9f5a134e2e01361bfb9edf44f982f821f0fdefb1 100644 (file)
@@ -305,6 +305,6 @@ out_ops:
 out_rtnl:
        rtnl_unlock();
 out_dev:
-       dev_put(dev);
+       ethnl_parse_header_dev_put(&req_info);
        return ret;
 }
index b91839870efc990119a51fc5ff63e62f35643491..efa0f7f488366c14bd44a03f8568f28fad017fed 100644 (file)
@@ -149,6 +149,6 @@ out_ops:
 out_rtnl:
        rtnl_unlock();
 out_dev:
-       dev_put(dev);
+       ethnl_parse_header_dev_put(&req_info);
        return ret;
 }
index f9eda596f301408ce145d2cb996023dd37b1a0f6..99b29b4fe9472f5e2de1c10ecd33d8248cd1687c 100644 (file)
@@ -358,6 +358,6 @@ out_ops:
 out_rtnl:
        rtnl_unlock();
 out_dev:
-       dev_put(dev);
+       ethnl_parse_header_dev_put(&req_info);
        return ret;
 }
index bc2cef11bbdad6649948289c47bc4fe0b6c4579b..898ed436b9e41db688a70e65e47b18ae1176d275 100644 (file)
@@ -175,6 +175,6 @@ out_ops:
        ethnl_ops_complete(dev);
 out_rtnl:
        rtnl_unlock();
-       dev_put(dev);
+       ethnl_parse_header_dev_put(&req_info);
        return ret;
 }
index a779bbb0c524f00e7a798bc8448bebbd43b65488..75856db299e9d3d2d1ba041ee8c9c32abe37ca53 100644 (file)
@@ -235,6 +235,11 @@ struct ethnl_req_info {
        u32                     flags;
 };
 
+static inline void ethnl_parse_header_dev_put(struct ethnl_req_info *req_info)
+{
+       dev_put_track(req_info->dev, &req_info->dev_tracker);
+}
+
 /**
  * struct ethnl_reply_data - base type of reply data for GET requests
  * @dev:       device for current reply message; in single shot requests it is
index ee1e5806bc93a4bf60fe18bf15ee9b01af190b62..a8c113d244db9c4e13f089ddb40e3d390f620148 100644 (file)
@@ -181,6 +181,6 @@ out_ops:
 out_rtnl:
        rtnl_unlock();
 out_dev:
-       dev_put(dev);
+       ethnl_parse_header_dev_put(&req_info);
        return ret;
 }
index fc9f3be23a19d82236bd001024237fb191d0e53c..4c7bfa81e4abf4c0478a9eae9892418113c87f09 100644 (file)
@@ -196,6 +196,6 @@ out_ops:
 out_rtnl:
        rtnl_unlock();
 out_dev:
-       dev_put(dev);
+       ethnl_parse_header_dev_put(&req_info);
        return ret;
 }
index 450b8866373d17d9318ca7802f946d36e646fc1e..c1d5f5e0fdc98e58de88e77d3c783be15022dc43 100644 (file)
@@ -196,6 +196,6 @@ out_ops:
 out_rtnl:
        rtnl_unlock();
 out_dev:
-       dev_put(dev);
+       ethnl_parse_header_dev_put(&req_info);
        return ret;
 }
index e7f2ee0d2471977a57761a89f0a1764a7dce82b1..efde3353668734d7d0457d721f8ecd7a4e0bc551 100644 (file)
@@ -195,7 +195,7 @@ int ethnl_tunnel_info_doit(struct sk_buff *skb, struct genl_info *info)
        if (ret)
                goto err_free_msg;
        rtnl_unlock();
-       dev_put(req_info.dev);
+       ethnl_parse_header_dev_put(&req_info);
        genlmsg_end(rskb, reply_payload);
 
        return genlmsg_reply(rskb, info);
@@ -204,7 +204,7 @@ err_free_msg:
        nlmsg_free(rskb);
 err_unlock_rtnl:
        rtnl_unlock();
-       dev_put(req_info.dev);
+       ethnl_parse_header_dev_put(&req_info);
        return ret;
 }
 
@@ -230,7 +230,7 @@ int ethnl_tunnel_info_start(struct netlink_callback *cb)
                                         sock_net(cb->skb->sk), cb->extack,
                                         false);
        if (ctx->req_info.dev) {
-               dev_put(ctx->req_info.dev);
+               ethnl_parse_header_dev_put(&ctx->req_info);
                ctx->req_info.dev = NULL;
        }
 
index ada7df2331d20d088a75ffcc1c210aff69c99791..88f435e76481d780f531c0e1eda5d29c4ae25a10 100644 (file)
@@ -165,6 +165,6 @@ out_ops:
 out_rtnl:
        rtnl_unlock();
 out_dev:
-       dev_put(dev);
+       ethnl_parse_header_dev_put(&req_info);
        return ret;
 }