Commit c1b013f8 authored by Jack Pham's avatar Jack Pham
Browse files

FROMGIT: usb: ucsi: Ensure connector delayed work items are flushed



During ucsi_unregister() when destroying a connector's workqueue, there
may still be pending delayed work items that haven't been scheduled yet.
Because queue_delayed_work() uses a separate timer to schedule a work
item, the destroy_workqueue() call is not aware of any pending items.
Hence when a pending item's timer expires it would then try to queue on
a dangling workqueue pointer.

Fix this by keeping track of all work items in a list, so that prior to
destroying the workqueue any pending items can be flushed.  Do this by
calling mod_delayed_work() as that will cause pending items to get
queued immediately, which then allows the ensuing destroy_workqueue() to
implicitly drain all currently queued items to completion and free
themselves.

Fixes: b9aa02ca ("usb: typec: ucsi: Add polling mechanism for partner tasks like alt mode checking")
Suggested-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Co-developed-by: default avatarLinyu Yuan <quic_linyyuan@quicinc.com>
Signed-off-by: default avatarLinyu Yuan <quic_linyyuan@quicinc.com>
Signed-off-by: default avatarJack Pham <quic_jackp@quicinc.com>
Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20230110071218.26261-1-quic_jackp@quicinc.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 265063961
(cherry picked from commit fac4b863
 git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git

 usb-linus)
Change-Id: Ia8a3e117648c503b6feba3957fd9665c4bf7a072
Signed-off-by: default avatarJack Pham <quic_jackp@quicinc.com>
parent 4bc9c561
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment