public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Paul Moses <p@1g4.org>
To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com
Cc: horms@kernel.org, jiri@resnulli.us, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, Paul Moses <p@1g4.org>,
	stable@vger.kernel.org
Subject: [PATCH net 2/2] net-shapers: don't free reply skb after genlmsg_reply()
Date: Mon, 09 Mar 2026 17:35:10 +0000	[thread overview]
Message-ID: <20260309173450.538026-2-p@1g4.org> (raw)
In-Reply-To: <20260309173450.538026-1-p@1g4.org>

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>
---
 net/shaper/shaper.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/net/shaper/shaper.c b/net/shaper/shaper.c
index 3ad5a2d621a91..ab0de415546d6 100644
--- a/net/shaper/shaper.c
+++ b/net/shaper/shaper.c
@@ -760,11 +760,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);
@@ -1314,10 +1310,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);
-- 
2.53.GIT



  reply	other threads:[~2026-03-09 17:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-09 17:35 [PATCH net 1/2] net-shapers: clear hierarchy pointer and defer flush frees with RCU Paul Moses
2026-03-09 17:35 ` Paul Moses [this message]
2026-03-11  2:28 ` Jakub Kicinski
2026-03-11 14:04   ` Paul Moses
2026-03-12  0:18     ` Jakub Kicinski
2026-03-12  6:05       ` Paul Moses
2026-03-12 14:25         ` Jakub Kicinski
2026-03-12 14:57           ` Paul Moses
2026-03-16 18:45   ` Paul Moses
2026-03-16 23:12     ` Jakub Kicinski
2026-03-16 23:41       ` Paul Moses
2026-03-16 23:59         ` Paul Moses
2026-03-11  2:40 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260309173450.538026-2-p@1g4.org \
    --to=p@1g4.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox