From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 238F03B9D84; Fri, 15 May 2026 16:16:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778861778; cv=none; b=u+VUzQEwLf0L42QCVMTdE6/eSrDfPidSp39kw8aDwPZget70npKSywADntHKlTYQJpGD75Es4yYm41lp9PZvw2bXHyuOPHmQuwyY++wDNAgmADciS9fext5AxAdS1g5YMs5jiuyQyL5iOBGKItSQYTJXAkUJLlBmA3JHDAoeCzQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778861778; c=relaxed/simple; bh=dAOgf82GdaWMTwRGTdOl/FJr+AeCT3HKRokdXpLznVE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GAj5IGoUMNQFNrGn2BxU2CjGCjDNQ6pz4Shd1neYMDkIUwE5+ISjjJ0XOGi1kNYcr4hNIRWyZu1MhCg9HdYvoM0wnkmSHCy7XnlYR1o9Xt/vvaFqzO5G3zY6mZ6U+l27gjsBB/Xj18ZcqrczGM16IdmLCBmvDABZsBTRtmHtRMg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=bxkYYwaI; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="bxkYYwaI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACECAC2BCB0; Fri, 15 May 2026 16:16:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778861778; bh=dAOgf82GdaWMTwRGTdOl/FJr+AeCT3HKRokdXpLznVE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bxkYYwaIJJirL8MPgUUNN73QFCrGJZpqxvM+oTpPBXtyseGsZ6uXSZwqw2sAuSey7 PwFNvZt5Hq0GlPmLZvEmeWe9XZhEN9fBGBAg3Il1QRFE+dP+lAHjT9oOPz/RpdCfqX 78dMaeCtjaYwvuCquk6lxDb1MwqfRERUB83FpCXI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable@kernel.org, Sven Eckelmann Subject: [PATCH 6.6 458/474] batman-adv: tp_meter: fix tp_num leak on kmalloc failure Date: Fri, 15 May 2026 17:49:27 +0200 Message-ID: <20260515154725.008710320@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260515154715.053014143@linuxfoundation.org> References: <20260515154715.053014143@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sven Eckelmann 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 Cc: stable@kernel.org Fixes: 33a3bb4a3345 ("batman-adv: throughput meter implementation") [ Context ] Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- net/batman-adv/tp_meter.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/batman-adv/tp_meter.c b/net/batman-adv/tp_meter.c index 7f3dd3c393e0..16da48b23f57 100644 --- a/net/batman-adv/tp_meter.c +++ b/net/batman-adv/tp_meter.c @@ -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; -- 2.47.3