]> git.itanic.dy.fi Git - linux-stable/commit
net: wwan: iosm: fix NULL pointer dereference when removing device
authorM Chetan Kumar <m.chetan.kumar@linux.intel.com>
Tue, 16 May 2023 15:39:46 +0000 (21:09 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 24 May 2023 16:32:47 +0000 (17:32 +0100)
commitee44bacf462db3ec6e4f0dcfa7931e768670d77c
treef9b3dd4567f258674f39fe17ea51c0af07aa2cb6
parentc3e3e8933faa9de87aa7040d7d7c9a4dd83fc967
net: wwan: iosm: fix NULL pointer dereference when removing device

[ Upstream commit 60829145f1e2650b31ebe6a0ec70a9725b38fa2c ]

In suspend and resume cycle, the removal and rescan of device ends
up in NULL pointer dereference.

During driver initialization, if the ipc_imem_wwan_channel_init()
fails to get the valid device capabilities it returns an error and
further no resource (wwan struct) will be allocated. Now in this
situation if driver removal procedure is initiated it would result
in NULL pointer exception since unallocated wwan struct is dereferenced
inside ipc_wwan_deinit().

ipc_imem_run_state_worker() to handle the called functions return value
and to release the resource in failure case. It also reports the link
down event in failure cases. The user space application can handle this
event to do a device reset for restoring the device communication.

Fixes: 3670970dd8c6 ("net: iosm: shared memory IPC interface")
Reported-by: Samuel Wein PhD <sam@samwein.com>
Closes: https://lore.kernel.org/netdev/20230427140819.1310f4bd@kernel.org/T/
Signed-off-by: M Chetan Kumar <m.chetan.kumar@linux.intel.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wwan/iosm/iosm_ipc_imem.c
drivers/net/wwan/iosm/iosm_ipc_imem_ops.c
drivers/net/wwan/iosm/iosm_ipc_imem_ops.h