From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dvalin.narfation.org (dvalin.narfation.org [213.160.73.56]) (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 E4C5247ECE9 for ; Fri, 15 May 2026 11:47:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.160.73.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778845655; cv=none; b=kocHUZ2hZCuZoVxfJ1CkUZK+RoHQtN73nSBr1UAJn1XBXFx89bCGM5/szTzOxj7+5q4Aha/641i4KoA9zIODELB8XynZ81EXLpOg2V/HYZwb24Bd3LDiN3C6O1GAPTmzfcFL++CfKjRlmYN2F72vQsqqQVtueb0WS5rw5tHh/Z0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778845655; c=relaxed/simple; bh=kGmryqy+a+FMsjBMV4M+etY2UajaUq+d808IIT3Itqk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dpFhuo1zwdIaIjLWVinKhzq1ufLeMBv/aGzBTfBTf/CUxi73dieUALuNhhj/CF3rD2zIPDb8gRylWTQ38sg9AdpfNHYabOIJQtQxhkmgOc8iO0mjy1X8mJMLSR1KZ9fzoensx341H6z9/fXItN4s9tGh6ZSr99ct4jWMuK13e20= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=narfation.org; spf=pass smtp.mailfrom=narfation.org; dkim=pass (1024-bit key) header.d=narfation.org header.i=@narfation.org header.b=c5hcu0b8; arc=none smtp.client-ip=213.160.73.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=narfation.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=narfation.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=narfation.org header.i=@narfation.org header.b="c5hcu0b8" Received: by dvalin.narfation.org (Postfix) id 2DD5C20059; Fri, 15 May 2026 11:47:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=narfation.org; s=20121; t=1778845648; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H/EecNu/N2Ed01zHu7NWps+Bp3pUTWOkuEgkRFkQGmw=; b=c5hcu0b8d2TudsZUJXmqdRSXVW4xUnLcsurp70eolseSKmiEq5Xrc8sCKBA5QFaR8CY66h 1KNCN4Mc2Q2vHoS9RswEjF04vjfkaJ7TXLrIxovA2yTcgT9S0N5alFBd0Td4YIV/lfcnI4 2wqSB1zQGMscOTe0JL6ZoykuNJz7ifI= From: Sven Eckelmann To: stable@vger.kernel.org Cc: Sven Eckelmann , stable@kernel.org Subject: [PATCH 6.12.y] batman-adv: tp_meter: fix tp_num leak on kmalloc failure Date: Fri, 15 May 2026 13:47:18 +0200 Message-ID: <20260515114718.410490-1-sven@narfation.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <2026051519-pound-zippy-6d5f@gregkh> References: <2026051519-pound-zippy-6d5f@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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