FAILED: patch "[PATCH] batman-adv: tp_meter: fix tp_num leak on kmalloc failure" failed to apply to 6.1-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x ce425dd05d0fe7594930a0fb103634f35ac47bb6
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026051520-obnoxious-editor-0139@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From ce425dd05d0fe7594930a0fb103634f35ac47bb6 Mon Sep 17 00:00:00 2001
From: Sven Eckelmann <[email protected]>
Date: Wed, 6 May 2026 22:20:49 +0200
Subject: [PATCH] batman-adv: tp_meter: fix tp_num leak on kmalloc failure
When batadv_tp_start() or batadv_tp_init_recv() fail to allocate a new tp_vars object, the previously incremented bat_priv->tp_num counter is never decremented. This causes tp_num to drift upward on each allocation failure. Since only BATADV_TP_MAX_NUM sessions can be started and the count is never reduced for these failed allocations, it causes to an exhaustion of throughput meter sessions. In worst case, no new throughput meter session can be started until the mesh interface is removed.
The error handling must decrement tp_num releasing the lock and aborting the creation of an throughput meter session
net/batman-adv/tp_meter.c +4 -1
@@ -994,6 +994,7 @@ void batadv_tp_start(struct batadv_priv *bat_priv, const u8 *dst, tp_vars =kmalloc_obj (*tp_vars,GFP_ATOMIC );if (!tp_vars) { +atomic_dec (&bat_priv->tp_num);spin_unlock_bh (&bat_priv->tp_list_lock); batadv_dbg(BATADV_DBG_TP_METER, bat_priv, "Meter: %s cannot allocate list elements\n",
@@ -1366,8 +1367,10 @@ batadv_tp_init_recv(struct batadv_priv *bat_priv, } tp_vars =kmalloc_obj (*tp_vars,GFP_ATOMIC ); -if (!tp_vars) +if (!tp_vars) { +atomic_dec (&bat_priv->tp_num); goto out_unlock; + }ether_addr_copy (tp_vars->other_end, icmp->orig); tp_vars->role =BATADV_TP_RECEIVER ;
Sven Eckelmann
maintainerQuoted 1 line · On Friday, 15 May 2026 10:45:20 CEST [email protected] wrote:
git send-email --to '<[email protected]>' --in-reply-to '2026051520-obnoxious-editor-0139@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..
@Greg, I will take care of backporting the failed batman-adv patches in an hour or so. The steps you provide in the mail are always super helpful to stay focused and do everything step by step.
But I've noticed that on a shell with "extended_glob" enabled, the shell tries to match the last parameter because it sees the '^' character. Maybe you could also quote it too:
-git send-email --to '<[email protected]>' --in-reply-to '2026051520-obnoxious-editor-0139@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^.. +git send-email --to '<[email protected]>' --in-reply-to '2026051520-obnoxious-editor-0139@gregkh' --subject-prefix 'PATCH 6.1.y' 'HEAD^..'
Btw. I've just disabled it here on my shell. But maybe this is still interesting for others
Thanks,
Sven
Greg KH
maintainerQuoted 14 lines · Sven Eckelmann
Quoted 1 line · On Friday, 15 May 2026 10:45:20 CEST [email protected] wrote:
git send-email --to '<[email protected]>' --in-reply-to '2026051520-obnoxious-editor-0139@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..
@Greg, I will take care of backporting the failed batman-adv patches in an hour or so. The steps you provide in the mail are always super helpful to stay focused and do everything step by step.
But I've noticed that on a shell with "
extended_glob" enabled, the shell tries to match the last parameter because it sees the '^' character. Maybe you could also quote it too:(quoted diff) +1
-1-git send-email --to '<[email protected]>' --in-reply-to '2026051520-obnoxious-editor-0139@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^.. +git send-email --to '<[email protected]>' --in-reply-to '2026051520-obnoxious-editor-0139@gregkh' --subject-prefix 'PATCH 6.1.y' 'HEAD^..'
Quoted 2 lines
Btw. I've just disabled it here on my shell. But maybe this is still interesting for others
Ah nice catch, I'll go update my script to put the '' in there, thanks.
greg k-h
Sven Eckelmann
maintainerPATCH 1/1 batman-adv: tp_meter: fix tp_num leak on kmalloc failure
In reply to [email protected]commit ce425dd05d0fe7594930a0fb103634f35ac47bb6 upstream.
When batadv_tp_start() or batadv_tp_init_recv() fail to allocate a new tp_vars object, the previously incremented bat_priv->tp_num counter is never decremented. This causes tp_num to drift upward on each allocation failure. Since only BATADV_TP_MAX_NUM sessions can be started and the count is never reduced for these failed allocations, it causes to an exhaustion of throughput meter sessions. In worst case, no new throughput meter session can be started until the mesh interface is removed.
The error handling must decrement tp_num releasing the lock and aborting the creation of an throughput meter session
--- net/batman-adv/tp_meter.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/batman-adv/tp_meter.c +4 -1
@@ -969,6 +969,7 @@ void batadv_tp_start(struct batadv_priv *bat_priv, const u8 *dst, tp_vars =kmalloc (sizeof (*tp_vars),GFP_ATOMIC );if (!tp_vars) { +atomic_dec (&bat_priv->tp_num);spin_unlock_bh (&bat_priv->tp_list_lock); batadv_dbg(BATADV_DBG_TP_METER, bat_priv, "Meter: %s cannot allocate list elements\n",
@@ -1344,8 +1345,10 @@ batadv_tp_init_recv(struct batadv_priv *bat_priv, } tp_vars =kmalloc (sizeof (*tp_vars),GFP_ATOMIC ); -if (!tp_vars) +if (!tp_vars) { +atomic_dec (&bat_priv->tp_num); goto out_unlock; + }ether_addr_copy (tp_vars->other_end, icmp->orig); tp_vars->role =BATADV_TP_RECEIVER ;
Signature · 1 line
2.47.3