mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] bus: mhi: ep: cancel reset work during controller teardown
@ 2026-10-21 11:04 Jiale Yao
  2026-10-28 21:33 ` Jeff Hugo
  0 siblings, 1 reply; 2+ messages in thread
From: Jiale Yao @ 2026-10-21 11:04 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Jeff Hugo, Alex Elder, Greg Kroah-Hartman,
	mhi, linux-arm-msm, linux-kernel
  Cc: stable

The doorbell IRQ schedules reset_work on the system workqueue when the
host requests an MHI reset. The controller teardown only drains the
private MHI workqueue before releasing the controller state, so
reset_work can still run after that state has been freed.

Cancel reset_work before destroying the private workqueue and releasing
the controller resources. The caller is required to power down the
controller first, so the IRQ can no longer queue the work at this point.

The issue was found by static analysis. The fix was tested with an
out-of-tree module that registers a real mhi_ep_cntrl backed by a
software IRQ and a fake register file. The module drives mhi_ep_irq()
and mhi_ep_unregister_controller(), and delays the reset worker until
after the controller state has been freed. Without this fix, KASAN
reports a slab-use-after-free in mhi_ep_ring_init() from
mhi_ep_reset_worker. With this fix applied, controller teardown waits
for the reset worker and the KASAN report is no longer reproduced.

Fixes: 7a97b6b47353 ("bus: mhi: ep: Add support for handling MHI_RESET")
Cc: stable@vger.kernel.org
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---

Changes in v2:
- Document how the issue was found and tested.
- Add Cc: stable@vger.kernel.org.

 drivers/bus/mhi/ep/main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c
index db7ee6547eef..a9695e1a75ab 100644
--- a/drivers/bus/mhi/ep/main.c
+++ b/drivers/bus/mhi/ep/main.c
@@ -1596,6 +1596,7 @@ void mhi_ep_unregister_controller(struct mhi_ep_cntrl *mhi_cntrl)
 {
 	struct mhi_ep_device *mhi_dev = mhi_cntrl->mhi_dev;
 
+	cancel_work_sync(&mhi_cntrl->reset_work);
 	destroy_workqueue(mhi_cntrl->wq);
 
 	free_irq(mhi_cntrl->irq, mhi_cntrl);
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] bus: mhi: ep: cancel reset work during controller teardown
  2026-10-21 11:04 [PATCH v2] bus: mhi: ep: cancel reset work during controller teardown Jiale Yao
@ 2026-10-28 21:33 ` Jeff Hugo
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Hugo @ 2026-10-28 21:33 UTC (permalink / raw)
  To: Jiale Yao, Manivannan Sadhasivam, Alex Elder, Greg Kroah-Hartman,
	mhi, linux-arm-msm, linux-kernel
  Cc: stable

On 10/21/2026 5:04 AM, Jiale Yao wrote:
> The doorbell IRQ schedules reset_work on the system workqueue when the
> host requests an MHI reset. The controller teardown only drains the
> private MHI workqueue before releasing the controller state, so
> reset_work can still run after that state has been freed.
> 
> Cancel reset_work before destroying the private workqueue and releasing
> the controller resources. The caller is required to power down the
> controller first, so the IRQ can no longer queue the work at this point.
> 
> The issue was found by static analysis. The fix was tested with an
> out-of-tree module that registers a real mhi_ep_cntrl backed by a
> software IRQ and a fake register file. The module drives mhi_ep_irq()
> and mhi_ep_unregister_controller(), and delays the reset worker until
> after the controller state has been freed. Without this fix, KASAN
> reports a slab-use-after-free in mhi_ep_ring_init() from
> mhi_ep_reset_worker. With this fix applied, controller teardown waits
> for the reset worker and the KASAN report is no longer reproduced.
> 
> Fixes: 7a97b6b47353 ("bus: mhi: ep: Add support for handling MHI_RESET")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jiale Yao <yaojiale02@163.com>
Reviewed-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-28 21:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-21 11:04 [PATCH v2] bus: mhi: ep: cancel reset work during controller teardown Jiale Yao
2026-10-28 21:33 ` Jeff Hugo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®