]> git.ipfire.org Git - thirdparty/linux.git/commit
batman-adv: bla: fix report_work leak on backbone_gw purge
authorSven Eckelmann <sven@narfation.org>
Sun, 10 May 2026 09:43:20 +0000 (11:43 +0200)
committerSven Eckelmann <sven@narfation.org>
Tue, 19 May 2026 07:09:34 +0000 (09:09 +0200)
commit0459430add32ea41f3e2ef9351610e6d33627a6b
treebbf1ca62add730ebd1442dece1fe1c5cc5179f03
parentaa3153bd139a6c48667dcd02608d3b2c80bff02c
batman-adv: bla: fix report_work leak on backbone_gw purge

batadv_bla_purge_backbone_gw() removes stale backbone gateway entries,
but fails to properly handle their associated report_work:

- If report_work is running, the purge must wait for it to finish before
  freeing the backbone_gw, otherwise the worker may access freed memory
  (e.g. bat_priv).
- If report_work is pending, the purge must cancel it and release the
  reference held for that pending work item.

The previous implementation called hlist_for_each_entry_safe() inside a
spin_lock_bh() section, but cancel_work_sync() may sleep and therefore
cannot be called from within a spinlock-protected region.

Restructure the loop to handle one entry per spinlock critical section:
acquire the lock, find the next entry to purge, remove it from the hash
list, then release the lock before calling cancel_work_sync() and
dropping the hash_entry reference. Repeat until no more entries require
purging.

Cc: stable@kernel.org
Fixes: 23721387c409 ("batman-adv: add basic bridge loop avoidance code")
Reviewed-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
net/batman-adv/bridge_loop_avoidance.c