Andrew Lunn pointed out that even if it's documented that ethnl_parse_header() takes reference to network device if it fills it into the target structure, its name doesn't make it apparent so that corresponding dev_put() looks like mismatched. Rename the function ethnl_parse_header_dev_get() to indicate that it takes a reference.
Unified · Split
| @@ -102,8 +102,10 @@ int ethnl_set_debug(struct sk_buff *skb, struct genl_info *info) · 101 unmodified lines | ||
| 102 | 102 | info->extack); |
| 103 | 103 | if (ret < 0) |
| 104 | 104 | return ret; |
| 105 | − ret = ethnl_parse_header(&req_info, tb[ETHTOOL_A_DEBUG_HEADER], | |
| 106 | − genl_info_net(info), info->extack, true); | |
| 105 | + ret = ethnl_parse_header_dev_get(&req_info, | |
| 106 | + tb[ETHTOOL_A_DEBUG_HEADER], | |
| 107 | + genl_info_net(info), info->extack, | |
| 108 | + true); | |
| 107 | 109 | if (ret < 0) |
| 108 | 110 | return ret; |
| 109 | 111 | dev = req_info.dev; |
| @@ -121,8 +121,10 @@ int ethnl_set_linkinfo(struct sk_buff *skb, struct genl_info *info) · 120 unmodified lines | ||
| 121 | 121 | info->extack); |
| 122 | 122 | if (ret < 0) |
| 123 | 123 | return ret; |
| 124 | − ret = ethnl_parse_header(&req_info, tb[ETHTOOL_A_LINKINFO_HEADER], | |
| 125 | − genl_info_net(info), info->extack, true); | |
| 124 | + ret = ethnl_parse_header_dev_get(&req_info, | |
| 125 | + tb[ETHTOOL_A_LINKINFO_HEADER], | |
| 126 | + genl_info_net(info), info->extack, | |
| 127 | + true); | |
| 126 | 128 | if (ret < 0) |
| 127 | 129 | return ret; |
| 128 | 130 | dev = req_info.dev; |
| @@ -334,8 +334,10 @@ int ethnl_set_linkmodes(struct sk_buff *skb, struct genl_info *info) · 333 unmodified lines | ||
| 334 | 334 | info->extack); |
| 335 | 335 | if (ret < 0) |
| 336 | 336 | return ret; |
| 337 | − ret = ethnl_parse_header(&req_info, tb[ETHTOOL_A_LINKMODES_HEADER], | |
| 338 | − genl_info_net(info), info->extack, true); | |
| 337 | + ret = ethnl_parse_header_dev_get(&req_info, | |
| 338 | + tb[ETHTOOL_A_LINKMODES_HEADER], | |
| 339 | + genl_info_net(info), info->extack, | |
| 340 | + true); | |
| 339 | 341 | if (ret < 0) |
| 340 | 342 | return ret; |
| 341 | 343 | dev = req_info.dev; |
| @@ -18,7 +18,7 @@ static const struct nla_policy ethnl_header_policy[ETHTOOL_A_HEADER_MAX + 1] = { · 17 unmodified lines | ||
| 18 | 18 | }; |
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | − * ethnl_parse_header() - parse request header | |
| 21 | + * ethnl_parse_header_dev_get() - parse request header | |
| 22 | 22 | * @req_info: structure to put results into |
| 23 | 23 | * @header: nest attribute with request header |
| 24 | 24 | * @net: request netns |
| @@ -33,9 +33,9 @@ static const struct nla_policy ethnl_header_policy[ETHTOOL_A_HEADER_MAX + 1] = { · 8 unmodified lines | ||
| 33 | 33 | * |
| 34 | 34 | * Return: 0 on success or negative error code |
| 35 | 35 | */ |
| 36 | −int ethnl_parse_header(struct ethnl_req_info *req_info, | |
| 37 | − const struct nlattr *header, struct net *net, | |
| 38 | − struct netlink_ext_ack *extack, bool require_dev) | |
| 36 | +int ethnl_parse_header_dev_get(struct ethnl_req_info *req_info, | |
| 37 | + const struct nlattr *header, struct net *net, | |
| 38 | + struct netlink_ext_ack *extack, bool require_dev) | |
| 39 | 39 | { |
| 40 | 40 | struct nlattr *tb[ETHTOOL_A_HEADER_MAX + 1]; |
| 41 | 41 | const struct nlattr *devname_attr; |
| @@ -253,8 +253,8 @@ static int ethnl_default_parse(struct ethnl_req_info *req_info, · 211 unmodified lines | ||
| 253 | 253 | request_ops->request_policy, extack); |
| 254 | 254 | if (ret < 0) |
| 255 | 255 | goto out; |
| 256 | − ret = ethnl_parse_header(req_info, tb[request_ops->hdr_attr], net, | |
| 257 | − extack, require_dev); | |
| 256 | + ret = ethnl_parse_header_dev_get(req_info, tb[request_ops->hdr_attr], | |
| 257 | + net, extack, require_dev); | |
| 258 | 258 | if (ret < 0) |
| 259 | 259 | goto out; |
| 260 | 260 | |
| @@ -10,9 +10,10 @@ · 9 unmodified lines | ||
| 10 | 10 | |
| 11 | 11 | struct ethnl_req_info; |
| 12 | 12 | |
| 13 | −int ethnl_parse_header(struct ethnl_req_info *req_info, | |
| 14 | − const struct nlattr *nest, struct net *net, | |
| 15 | − struct netlink_ext_ack *extack, bool require_dev); | |
| 13 | +int ethnl_parse_header_dev_get(struct ethnl_req_info *req_info, | |
| 14 | + const struct nlattr *nest, struct net *net, | |
| 15 | + struct netlink_ext_ack *extack, | |
| 16 | + bool require_dev); | |
| 16 | 17 | int ethnl_fill_reply_header(struct sk_buff *skb, struct net_device *dev, |
| 17 | 18 | u16 attrtype); |
| 18 | 19 | struct sk_buff *ethnl_reply_init(size_t payload, struct net_device *dev, u8 cmd, |
| @@ -123,8 +123,9 @@ int ethnl_set_wol(struct sk_buff *skb, struct genl_info *info) · 122 unmodified lines | ||
| 123 | 123 | wol_set_policy, info->extack); |
| 124 | 124 | if (ret < 0) |
| 125 | 125 | return ret; |
| 126 | − ret = ethnl_parse_header(&req_info, tb[ETHTOOL_A_WOL_HEADER], | |
| 127 | − genl_info_net(info), info->extack, true); | |
| 126 | + ret = ethnl_parse_header_dev_get(&req_info, tb[ETHTOOL_A_WOL_HEADER], | |
| 127 | + genl_info_net(info), info->extack, | |
| 128 | + true); | |
| 128 | 129 | if (ret < 0) |
| 129 | 130 | return ret; |
| 130 | 131 | dev = req_info.dev; |