Re: [PATCH] auxdisplay: seg-led-gpio: fix work initialization race and convert to devm_add_action_or_reset()
From: Andy Shevchenko
Date: Sun Aug 02 2026 - 05:30:13 EST
On Fri, Jul 24, 2026 at 5:55 AM <kr494167@xxxxxxxxx> wrote:
>
> From: Surendra Singh Chouhan <kr494167@xxxxxxxxx>
>
> INIT_DELAYED_WORK(&priv->work, seg_led_update) was previously called inside
> seg_led_linedisp_get_map_type(), which is invoked during/after
> linedisp_register(). Initializing a delayed_work structure inside a map
> query callback can re-initialize an active work item or race with
> seg_led_linedisp_update().
>
> In addition, seg_led_remove() called cancel_delayed_work_sync(&priv->work)
> before linedisp_unregister(&priv->linedisp), allowing sysfs updates to
> reschedule work after cancel_delayed_work_sync() completed.
>
> Fix these by moving INIT_DELAYED_WORK() to probe() and using
> devm_add_action_or_reset() for devm-managed cleanup. Registering
> seg_led_unregister_linedisp after seg_led_cancel_work ensures proper LIFO
> teardown order (sysfs interface unregistered first, followed by work
> cancellation), allowing seg_led_remove() to be removed entirely.
I think we have more drivers than this one with the same issue, no? If
so, can we solve this once for all (the existing and possible future
ones)?
--
With Best Regards,
Andy Shevchenko