Re: [PATCH v2] batman-adv: handle errors in batadv_init()

From: Sven Eckelmann

Date: Wed Jul 29 2026 - 11:41:33 EST


On Wed, 29 Jul 2026 16:44:35 +0800, Minhong He <heminhong@xxxxxxxxxx> wrote:
> batadv_init() ignores errors from several initialization helpers, so the
> module can load without those registrations in place.
>
> Check the fallible init steps and unwind prior initialization in reverse
> order of acquisition on failure.
>
> Signed-off-by: Minhong He <heminhong@xxxxxxxxxx>

Please don't send new versions as reply to the old version.

"batadv" would be correct prefix for the batadv.git repo at
https://git.open-mesh.org/batadv.git. So something like "[PATCH batadv v2]"

>
>
> diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
> index 73becb0549488..8fe8a2b27a744 100644
> --- a/net/batman-adv/main.c
> +++ b/net/batman-adv/main.c
> @@ -94,35 +94,63 @@ static int __init batadv_init(void)
> [ ... skip 52 lines ... ]
> +err_wifi:
> destroy_workqueue(batadv_event_workqueue);
> batadv_event_workqueue = NULL;
> rcu_barrier();
> + batadv_wifi_net_devices_deinit();
> + goto err_iv;

No, this is hard to see an will attract the goto raptor.

Feel free to move the "ret = batadv_wifi_net_devices_init();" before the
"batadv_event_workqueue = create_singlethread_workqueue("bat_events");" to keep
the reverse deinit order and only have a single rcu_barrier().

--
Sven Eckelmann <sven@xxxxxxxxxxxxx>