From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 54FB334751B; Tue, 16 Jun 2026 19:01:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781636499; cv=none; b=ZzRC1f13lbHGffacE2AaE2ClnQBkWi9coq1PeJDbPj3A8Rp74xDZuBbIyGpbpxWBnq0zQ5J+JawKX0vR3IM0zZ7grT/adVdlzkAXkMbsL+2L0efF8vio5i1+u/uxWnVbCnoLHbak1IWcUftQPjV2su2vhOCXAt/jN8iPKl2hNhs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781636499; c=relaxed/simple; bh=32I4zom79fzsiBTchUVr7vZ1816i3VSqRdPq3iw4soI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RQTdVVb+F6SRG2P1WyprmhfCW8WNUIAHWP2R2Ud+AlJQVltrOhngznFljAEtvrYlZoYyrt7TNudkScpNkAIHPncoIxa+y4v97OsXt5X/ClC1LeSp3beNADkfQmVrZ9KlihkuqRneeZ5qt/3olmRO94WxGNeUFzylYwwzZqN08Og= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=zfCkRf2G; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="zfCkRf2G" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56F3B1F000E9; Tue, 16 Jun 2026 19:01:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781636498; bh=TPLXHo258hcp4SJi1wY2fUFvZhGaLphuc8KHqsiXz6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=zfCkRf2GDcSG2EguwAEO/aK/mfgxkzo6PTWBP4ijb5M/Q1c/clO/4507PglAkApcg IhBrHAgr27JNSkOiq2K89Z6wuXtr+J9l++Mau6HphRKIdZozea/2EdLo9UKCvNe5XU 5W39CxW8jwi4QszSwY1MgZYfzGDTBz6hqcx03eVY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable@kernel.org, Sven Eckelmann Subject: [PATCH 5.10 217/342] batman-adv: tp_meter: fix tp_num leak on kmalloc failure Date: Tue, 16 Jun 2026 20:28:33 +0530 Message-ID: <20260616145058.304158197@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145048.348037099@linuxfoundation.org> References: <20260616145048.348037099@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-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") Signed-off-by: Sven Eckelmann [ 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(-) --- a/net/batman-adv/tp_meter.c +++ b/net/batman-adv/tp_meter.c @@ -1036,6 +1036,7 @@ void batadv_tp_start(struct batadv_priv 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", @@ -1410,8 +1411,10 @@ batadv_tp_init_recv(struct batadv_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;