A single fix targeting the MHI host stack:

 - Since the commit 1227d2a20cd7 ("bus: mhi: host: Move IRQ allocation to
   controller registration phase"), the MHI context gets freed during
   mhi_unregister_controller(). But when the MHI IRQs are shared, the IRQ
   handler may get invoked during __free_irq() if CONFIG_DEBUG_SHIRQ is set.
   In that case, there will be a null pointer dereference because of trying to
   use the freed context struct.

   So for fixing the issue, let's check for the existence of the context struct
   at the start of the handler before handling the IRQ.
bus: mhi: host: Fix up null pointer access in mhi_irq_handler

The irq handler for a shared IRQ ought to be prepared for running
even now it's being freed. So let's check the pointer used by
mhi_irq_handler to avoid null pointer access since it is probably
released before freeing IRQ.

Fixes: 1227d2a20cd7 ("bus: mhi: host: Move IRQ allocation to controller registration phase")
Signed-off-by: Qiang Yu <quic_qianyu@quicinc.com>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Tested-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/1658459838-30802-1-git-send-email-quic_qianyu@quicinc.com
[mani: added fixes tag]
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
1 file changed