]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ethtool: tsconfig: fix reply error handling
authorJakub Kicinski <kuba@kernel.org>
Tue, 26 May 2026 15:35:25 +0000 (08:35 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 28 May 2026 00:42:08 +0000 (17:42 -0700)
A couple of trivial bugs in error handling in tsconfig_send_reply().
If we failed to allocate rskb we need to set the error.
If we did allocate it but failed to send it - we need to remember
to free it.

Fixes: 6e9e2eed4f39 ("net: ethtool: Add support for tsconfig command to get/set hwtstamp config")
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>
Link: https://patch.msgid.link/20260526153533.2779187-3-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ethtool/tsconfig.c

index e4f518e49d4cb01d620c2949cfa91dd9785f5b8e..e9db4ee2299df777b88aea49c596411cf1a5e5b9 100644 (file)
@@ -224,16 +224,21 @@ static int tsconfig_send_reply(struct net_device *dev, struct genl_info *info)
        reply_len = ret + ethnl_reply_header_size();
        rskb = ethnl_reply_init(reply_len, dev, ETHTOOL_MSG_TSCONFIG_SET_REPLY,
                                ETHTOOL_A_TSCONFIG_HEADER, info, &reply_payload);
-       if (!rskb)
+       if (!rskb) {
+               ret = -ENOMEM;
                goto err_cleanup;
+       }
 
        ret = tsconfig_fill_reply(rskb, &req_info->base, &reply_data->base);
        if (ret < 0)
-               goto err_cleanup;
+               goto err_free_msg;
 
        genlmsg_end(rskb, reply_payload);
        ret = genlmsg_reply(rskb, info);
+       rskb = NULL;
 
+err_free_msg:
+       nlmsg_free(rskb);
 err_cleanup:
        kfree(reply_data);
        kfree(req_info);