]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
batman-adv: tp_meter: fix race condition in send error reporting
authorSven Eckelmann <sven@narfation.org>
Wed, 13 May 2026 21:38:54 +0000 (23:38 +0200)
committerSven Eckelmann <sven@narfation.org>
Tue, 19 May 2026 06:24:23 +0000 (08:24 +0200)
commit71dce47f0758537fff78fddb5fb0d4632d29b29f
treede27cfdbf2e3f6dd14f472c15ca0ccdacd95b9ef
parentf50487e3566358b2b982b7801945e858c78ad9ab
batman-adv: tp_meter: fix race condition in send error reporting

batadv_tp_sender_shutdown() previously used two separate variables to track
session state: sending (an atomic flag indicating whether the session was
active) and reason (a plain enum storing the stop reason). This introduced
a race window between the two writes: after sending was cleared to 0,
batadv_tp_send() could observe the stopped state and call
batadv_tp_sender_end() before reason was written, causing the wrong stop
reason to be reported to the caller.

Fix this by consolidating both variables into a single atomic send_result,
which holds 0 while the session is running and the stop reason once it
ends.

Cc: stable@kernel.org
Fixes: 33a3bb4a3345 ("batman-adv: throughput meter implementation")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
net/batman-adv/tp_meter.c
net/batman-adv/types.h