Re: [PATCH] misc: hisi_hikey_usb: cancel role switch work on remove
From: John Stultz
Date: Tue Jul 28 2026 - 22:55:25 EST
On Mon, Jul 27, 2026 at 11:56 PM Hongyan Xu <getshell@xxxxxxxxxx> wrote:
>
> The hub role switch set callback schedules private work that dereferences
> both driver data and the downstream role switch. Unregistering the hub
> switch does not drain work already queued, and a callback that fetched
> driver data before unregister can queue more work during removal.
>
> Mark the instance as removing under its mutex and serialize removal
> with role switch set callbacks by setting the role to USB_ROLE_NONE.
> The callback clears the switch driver data when it observes removal and
> no longer queues work. Unregister the switch, cancel the work, and only
> then drop the downstream role switch reference.
>
> This issue was found by a static analysis tool.
>
> Signed-off-by: Hongyan Xu <getshell@xxxxxxxxxx>
> ---
> drivers/misc/hisi_hikey_usb.c | 27 +++++++++++++++++++++------
> 1 file changed, 21 insertions(+), 6 deletions(-)
>
I no longer have hardware to test with, but on quick glance this looks
reasonable to me. Adding Linaro folks who might still be able to test
and validate.
For what it's worth:
Acked-by: John Stultz <jstultz@xxxxxxxxxx>