Re: [PATCH v2] usb: typec: ucsi: gaokun: unwind notifier on UCSI register failure

From: Greg Kroah-Hartman

Date: Wed Jul 08 2026 - 08:11:50 EST


On Mon, Jun 22, 2026 at 11:32:30PM +0800, Pengpeng Hou wrote:
> gaokun_ucsi_register_worker() registers the EC notifier before calling
> ucsi_register(). If ucsi_register() fails, the worker currently only logs
> the error and leaves the notifier registered. Later EC events can then
> call into an unpublished UCSI instance. The remove path also
> unconditionally unregisters the notifier and UCSI device even if the
> delayed worker failed before both were published.
>
> Unregister the notifier immediately when ucsi_register() fails, and track
> only the fully published state. The remove path then tears down the pair
> only if both publication steps completed.
>
> Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
> ---
> Changes since v1:
> - Drop the two-flag bookkeeping objected to by Greg Kroah-Hartman.
> - Keep the existing registration order, but use a single flag that is set
> only after both the notifier and UCSI device are published.
> - Unregister the EC notifier immediately if ucsi_register() fails.
> - Compile-tested only; no Gaokun hardware was available.

Does not apply against 7.2-rc2 :(