ethtool: use ethnl_parse_header_dev_put()

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: e4b8954074 ("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>
This commit is contained in:
Eric Dumazet 2021-12-14 00:42:30 -08:00 committed by David S. Miller
parent 6cf7a1ac0f
commit 34ac17ecbf
16 changed files with 23 additions and 18 deletions

View 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;
}

View 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;
}

View 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;
}

View 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;
}

View 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;
}

View 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;
}

View 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;
}

View 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;
}

View 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;
}

View 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;
}

View 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

View 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;
}

View 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;
}

View 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;
}

View 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;
}

View 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;
}