]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net-shapers: don't free reply skb after genlmsg_reply()
authorPaul Moses <p@1g4.org>
Mon, 9 Mar 2026 17:35:10 +0000 (17:35 +0000)
committerJakub Kicinski <kuba@kernel.org>
Wed, 11 Mar 2026 02:29:09 +0000 (19:29 -0700)
genlmsg_reply() hands the reply skb to netlink, and
netlink_unicast() consumes it on all return paths, whether the
skb is queued successfully or freed on an error path.

net_shaper_nl_get_doit() and net_shaper_nl_cap_get_doit()
currently jump to free_msg after genlmsg_reply() fails and call
nlmsg_free(msg), which can hit the same skb twice.

Return the genlmsg_reply() error directly and keep free_msg
only for pre-reply failures.

Fixes: 4b623f9f0f59 ("net-shapers: implement NL get operation")
Fixes: 553ea9f1efd6 ("net: shaper: implement introspection support")
Cc: stable@vger.kernel.org
Signed-off-by: Paul Moses <p@1g4.org>
Link: https://patch.msgid.link/20260309173450.538026-2-p@1g4.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/shaper/shaper.c

index 005bfc766e22d2bdb293ddd1f54e71e0d30399a1..3fd6629cb99923ec83955bebe9db86410d33e616 100644 (file)
@@ -759,11 +759,7 @@ int net_shaper_nl_get_doit(struct sk_buff *skb, struct genl_info *info)
        if (ret)
                goto free_msg;
 
-       ret = genlmsg_reply(msg, info);
-       if (ret)
-               goto free_msg;
-
-       return 0;
+       return genlmsg_reply(msg, info);
 
 free_msg:
        nlmsg_free(msg);
@@ -1313,10 +1309,7 @@ int net_shaper_nl_cap_get_doit(struct sk_buff *skb, struct genl_info *info)
        if (ret)
                goto free_msg;
 
-       ret =  genlmsg_reply(msg, info);
-       if (ret)
-               goto free_msg;
-       return 0;
+       return genlmsg_reply(msg, info);
 
 free_msg:
        nlmsg_free(msg);