From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Pengpeng Hou <pengpeng@iscas.ac.cn>
Cc: Pengyu Luo <mitltlatltl@gmail.com>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: typec: ucsi: gaokun: unwind notifier on UCSI register failure
Date: Mon, 15 Jun 2026 08:58:48 +0200 [thread overview]
Message-ID: <2026061504-trowel-hefty-41ae@gregkh> (raw)
In-Reply-To: <20260615065358.93104-1-pengpeng@iscas.ac.cn>
On Mon, Jun 15, 2026 at 02:53:57PM +0800, Pengpeng Hou wrote:
> gaokun_ucsi_register_worker() registers the EC notifier before
> registering the UCSI device.
>
> If ucsi_register() fails, the worker only reports the error and leaves
> the notifier registered. Later EC events can then call back into an
> unregistered UCSI instance. The remove path also unconditionally
> unregisters both the notifier and UCSI device even when the delayed
> worker failed part way through registration.
>
> Track which publication steps succeeded, unregister the EC notifier when
> UCSI registration fails, and make remove only undo the steps that were
> actually published.
>
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
> ---
> drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c | 16 +++++++++++++---
> 1 file changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c b/drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c
> index ca749fde49bd..29d2e76b2fe9 100644
> --- a/drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c
> +++ b/drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c
> @@ -98,6 +98,8 @@ struct gaokun_ucsi {
> struct device *dev;
> struct delayed_work work;
> struct notifier_block nb;
> + bool notifier_registered;
> + bool ucsi_registered;
> u16 version;
> u8 num_ports;
> };
> @@ -457,10 +459,16 @@ static void gaokun_ucsi_register_worker(struct work_struct *work)
> dev_err_probe(ucsi->dev, ret, "notifier register failed\n");
> return;
> }
> + uec->notifier_registered = true;
>
> ret = ucsi_register(ucsi);
> - if (ret)
> + if (ret) {
> dev_err_probe(ucsi->dev, ret, "ucsi register failed\n");
> + gaokun_ec_unregister_notify(uec->ec, &uec->nb);
> + uec->notifier_registered = false;
Why this convulted logic of setting to true and then false? Did you
have an AI write this?
And why are 2 flags needed? Are you sure that's necessary?
How was this tested?
thanks,
greg k-h
prev parent reply other threads:[~2026-06-15 7:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-15 6:53 [PATCH] usb: typec: ucsi: gaokun: unwind notifier on UCSI register failure Pengpeng Hou
2026-06-15 6:58 ` Greg Kroah-Hartman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2026061504-trowel-hefty-41ae@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mitltlatltl@gmail.com \
--cc=pengpeng@iscas.ac.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.