ipc_imem_cleanup() frees the MUX but leaves ipc_imem->mux pointing at it, so closing a netdev that is still up uses the freed MUX: BUG: KASAN: slab-use-after-free in ipc_mux_close_session Call Trace: ipc_mux_close_session ipc_wwan_link_stop __dev_close_many wwan_unregister_ops ipc_wwan_deinit ipc_imem_cleanup ipc_pcie_remove Clear the pointer after the free; ipc_imem_sys_wwan_close() already skips the session close when it is NULL. Do the same in the error path of the run state worker. Reproduced with KASAN on an XMM7360 by unbinding the driver while wwan0 is up. With this change, two such unbinds show no report. Fixes: 3670970dd8c6 ("net: iosm: shared memory IPC interface") Fixes: 60829145f1e2 ("net: wwan: iosm: fix NULL pointer dereference when removing device") Signed-off-by: David Westen --- Previously sent as patch 1/2 of a series: https://lore.kernel.org/netdev/20261126194143.32283-1-davidlwesten@gmail.com/ drivers/net/wwan/iosm/iosm_ipc_imem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wwan/iosm/iosm_ipc_imem.c b/drivers/net/wwan/iosm/iosm_ipc_imem.c index 4405c8531888..998493b730b0 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_imem.c +++ b/drivers/net/wwan/iosm/iosm_ipc_imem.c @@ -635,6 +635,7 @@ static void ipc_imem_run_state_worker(struct work_struct *instance) err_ipc_mux_deinit: ipc_mux_deinit(ipc_imem->mux); + ipc_imem->mux = NULL; err_out: ipc_uevent_send(ipc_imem->dev, UEVENT_CD_READY_LINK_DOWN); } @@ -1245,6 +1246,7 @@ void ipc_imem_cleanup(struct iosm_imem *ipc_imem) if (test_and_clear_bit(FULLY_FUNCTIONAL, &ipc_imem->flag)) { ipc_mux_deinit(ipc_imem->mux); + ipc_imem->mux = NULL; ipc_debugfs_deinit(ipc_imem); ipc_wwan_deinit(ipc_imem->wwan); ipc_port_deinit(ipc_imem->ipc_port); -- 2.56.0