Re: [PATCH 4/6] w1: Protect w1_masters traversal with w1_mlock during removal

From: Krzysztof Kozlowski

Date: Wed Dec 02 2026 - 05:45:01 EST


On 02/12/2026 10:36, Lee Jones wrote:
> w1_remove_master_device() and w1_fini() iterate over the global
> w1_masters list without holding w1_mlock, racing with concurrent
> w1_add_master_device() and w1_remove_master_device() calls that mutate
> the list. In addition, leaving list_del() to
> __w1_remove_master_device() creates a window in which two concurrent
> removals can find and tear down the same master device.
>
> Hold w1_mlock across lookup and list_del() in both
> w1_remove_master_device() and w1_fini(), and remove the now-redundant
> locking and list_del() from __w1_remove_master_device().
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Closes: https://sashiko.dev/#/bug/linux-568be2be-e67b-4b92-8416-512e4968f535
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
> ---

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxxxxxxxx>

Best regards,
Krzysztof