[PATCH v2 2/2] EDAC/device: Don't re-arm workqueue during teardown
Jad Keskes <[email protected]> Fri, 10 Jul 2026 12:35:48 +0100
| Newsgroups | org.kernel.vger.linux-edac,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
edac_device_del_device() stops the workqueue then removes the sysfs attributes. However, writing to poll_msec triggers edac_device_reset_delay_period(), which unconditionally re-arms the workqueue. If writes occur during that window, the re-armed work runs after edac_dev has been freed. Fix this by checking op_state in reset_delay_period(). del_device() already sets it to OP_OFFLINE before tearing down the workqueue, so the new guard causes reset_delay_period() to skip mod_work() when the device is being removed. Signed-off-by: Jad Keskes <[email protected]> --- drivers/edac/edac_device.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c index cf0d3c2dfc04..50ae7f1e5152 100644 --- a/drivers/edac/edac_device.c +++ b/drivers/edac/edac_device.c @@ -354,6 +354,10 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev, edac_dev->poll_msec = msec; edac_dev->delay = msecs_to_jiffies(msec); + /* Don't re-arm the workqueue if the device is being torn down */ + if (edac_dev->op_state == OP_OFFLINE) + return; + /* See comment in edac_device_workq_setup() above */ if (edac_dev->poll_msec == DEFAULT_POLL_INTERVAL) edac_mod_work(&edac_dev->work, round_jiffies_relative(edac_dev->delay)); -- 2.55.0