]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ethtool: count header size in reply size estimate
authorMichal Kubecek <mkubecek@suse.cz>
Sun, 10 May 2020 19:04:09 +0000 (21:04 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 21 May 2020 23:59:19 +0000 (16:59 -0700)
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: e9533c9ca90b ("ethtool: default handlers for GET requests")
Reported-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ethtool/netlink.c
net/ethtool/strset.c

index 0c772318c02321d8b6107f81c6d5fb48e21b61f6..ed53572101933e864ae10b45c66b989761598bf1 100644 (file)
@@ -342,7 +342,7 @@ static int ethnl_default_doit(struct sk_buff *skb, struct genl_info *info)
        ret = ops->reply_size(req_info, reply_data);
        if (ret < 0)
                goto err_cleanup;
-       reply_len = ret;
+       reply_len = ret + ethnl_reply_header_size();
        ret = -ENOMEM;
        rskb = ethnl_reply_init(reply_len, req_info->dev, ops->reply_cmd,
                                ops->hdr_attr, info, &reply_payload);
@@ -588,7 +588,7 @@ static void ethnl_default_notify(struct net_device *dev, unsigned int cmd,
        ret = ops->reply_size(req_info, reply_data);
        if (ret < 0)
                goto err_cleanup;
-       reply_len = ret;
+       reply_len = ret + ethnl_reply_header_size();
        ret = -ENOMEM;
        skb = genlmsg_new(reply_len, GFP_KERNEL);
        if (!skb)
index 95eae5c68a52420404d2e7cbcebb28b764056fc1..0eed4e4909ab86914be4948b2fe060816c49db45 100644 (file)
@@ -324,7 +324,6 @@ static int strset_reply_size(const struct ethnl_req_info *req_base,
        int len = 0;
        int ret;
 
-       len += ethnl_reply_header_size();
        for (i = 0; i < ETH_SS_COUNT; i++) {
                const struct strset_info *set_info = &data->sets[i];