Re: [PATCH 2/6] w1: Synchronise thread teardown with netlink callbacks

From: Krzysztof Kozlowski

Date: Wed Dec 02 2026 - 05:39:09 EST


On 02/12/2026 10:36, Lee Jones wrote:
> When __w1_remove_master_device() stops dev->thread via kthread_stop(),
> a concurrent w1_cn_callback() that already holds a reference on dev can
> still call wake_up_process(dev->thread) after the kthread task_struct
> has been freed, causing a use-after-free. In addition, draining queued
> netlink commands via w1_process_cb() during teardown can execute
> W1_CMD_SLAVE_ADD or W1_CMD_SEARCH after the master has already detached
> all slaves, re-attaching a slave and leaving dev->refcnt permanently
> non-zero.
>

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

Best regards,
Krzysztof