B.A.T.M.A.N Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH batadv] batman-adv: dat: initialize purge work before hash allocation
@ 2026-10-04  8:21 Sven Eckelmann
  2026-10-04  8:29 ` Sven Eckelmann
  0 siblings, 1 reply; 2+ messages in thread
From: Sven Eckelmann @ 2026-10-04  8:21 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Sven Eckelmann

batadv_dat_init() only initializes bat_priv->dat.work after the hash table
was allocated successfully. batadv_dat_free() unconditionally calls
disable_delayed_work_sync() on it.

This is currently not a problem: if batadv_mesh_init() fails,
batadv_dat_free() is never called. But as this might change in the future,
initialize the delayed work before anything in batadv_dat_init() can fail
to make sure that batadv_dat_free() always operates on an initialized work
item.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 net/batman-adv/distributed-arp-table.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
index 74050bff..cd95ce19 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -894,12 +894,13 @@ int batadv_dat_init(struct batadv_priv *bat_priv)
 	if (bat_priv->dat.hash)
 		return 0;
 
+	INIT_DELAYED_WORK(&bat_priv->dat.work, batadv_dat_purge);
+
 	bat_priv->dat.hash = batadv_hash_new(1024);
 
 	if (!bat_priv->dat.hash)
 		return -ENOMEM;
 
-	INIT_DELAYED_WORK(&bat_priv->dat.work, batadv_dat_purge);
 	batadv_dat_start_timer(bat_priv);
 
 	batadv_tvlv_handler_register(bat_priv, batadv_dat_tvlv_ogm_handler_v1,

---
base-commit: 4fa5cbac90fa7b8936779b4313debb3d89701c59
change-id: 20261004-dat-uninitialized-worker-d393c8bf8415

Best regards,
--  
Sven Eckelmann <sven@narfation.org>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH batadv] batman-adv: dat: initialize purge work before hash allocation
  2026-10-04  8:21 [PATCH batadv] batman-adv: dat: initialize purge work before hash allocation Sven Eckelmann
@ 2026-10-04  8:29 ` Sven Eckelmann
  0 siblings, 0 replies; 2+ messages in thread
From: Sven Eckelmann @ 2026-10-04  8:29 UTC (permalink / raw)
  To: b.a.t.m.a.n

[-- Attachment #1: Type: text/plain, Size: 827 bytes --]

On Sunday, 4 October 2026 10:21:58 CEST Sven Eckelmann wrote:
> batadv_dat_init() only initializes bat_priv->dat.work after the hash table
> was allocated successfully. batadv_dat_free() unconditionally calls
> disable_delayed_work_sync() on it.
> 
> This is currently not a problem: if batadv_mesh_init() fails,
> batadv_dat_free() is never called. But as this might change in the future,
> initialize the delayed work before anything in batadv_dat_init() can fail
> to make sure that batadv_dat_free() always operates on an initialized work
> item.

I think I will reject this patch because it is a little bit too defensive. 
Instead, I will simply reply to Sashiko that this isn't reachable. Similar to 
the batadv_v_ogm_free()'s mutex_lock() which isn't reachable when the alloc in 
batadv_v_ogm_init fails.

Regards,
	Sven

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-04  8:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-04  8:21 [PATCH batadv] batman-adv: dat: initialize purge work before hash allocation Sven Eckelmann
2026-10-04  8:29 ` Sven Eckelmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox