Skip to content

Commit 7c87e32

Browse files
mkubecekdavem330
authored andcommitted
ethtool: count header size in reply size estimate
As ethnl_request_ops::reply_size handlers do not include common header size into calculated/estimated reply size, it needs to be added in ethnl_default_doit() and ethnl_default_notify() before allocating the message. On the other hand, strset_reply_size() should not add common header size. Fixes: 728480f ("ethtool: default handlers for GET requests") Reported-by: Oleksij Rempel <[email protected]> Signed-off-by: Michal Kubecek <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d69100b commit 7c87e32

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

net/ethtool/netlink.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ static int ethnl_default_doit(struct sk_buff *skb, struct genl_info *info)
342342
ret = ops->reply_size(req_info, reply_data);
343343
if (ret < 0)
344344
goto err_cleanup;
345-
reply_len = ret;
345+
reply_len = ret + ethnl_reply_header_size();
346346
ret = -ENOMEM;
347347
rskb = ethnl_reply_init(reply_len, req_info->dev, ops->reply_cmd,
348348
ops->hdr_attr, info, &reply_payload);
@@ -588,7 +588,7 @@ static void ethnl_default_notify(struct net_device *dev, unsigned int cmd,
588588
ret = ops->reply_size(req_info, reply_data);
589589
if (ret < 0)
590590
goto err_cleanup;
591-
reply_len = ret;
591+
reply_len = ret + ethnl_reply_header_size();
592592
ret = -ENOMEM;
593593
skb = genlmsg_new(reply_len, GFP_KERNEL);
594594
if (!skb)

net/ethtool/strset.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ static int strset_reply_size(const struct ethnl_req_info *req_base,
324324
int len = 0;
325325
int ret;
326326

327-
len += ethnl_reply_header_size();
328327
for (i = 0; i < ETH_SS_COUNT; i++) {
329328
const struct strset_info *set_info = &data->sets[i];
330329

0 commit comments

Comments
 (0)