Commit ba0fbdb9 authored by Maxim Mikityanskiy's avatar Maxim Mikityanskiy Committed by David S. Miller

net: wwan: iosm: Call mutex_init before locking it

wwan_register_ops calls wwan_create_default_link, which ends up in the
ipc_wwan_newlink callback that locks ipc_wwan->if_mutex. However, this
mutex is not yet initialized by that point. Fix it by moving mutex_init
above the wwan_register_ops call. This also makes the order of
operations in ipc_wwan_init symmetric to ipc_wwan_deinit.

Fixes: 83068395 ("net: iosm: create default link via WWAN core")
Signed-off-by: default avatarMaxim Mikityanskiy <maxtram95@gmail.com>
Reviewed-by: default avatarM Chetan Kumar <m.chetan.kumar@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 12aece8b
...@@ -323,15 +323,16 @@ struct iosm_wwan *ipc_wwan_init(struct iosm_imem *ipc_imem, struct device *dev) ...@@ -323,15 +323,16 @@ struct iosm_wwan *ipc_wwan_init(struct iosm_imem *ipc_imem, struct device *dev)
ipc_wwan->dev = dev; ipc_wwan->dev = dev;
ipc_wwan->ipc_imem = ipc_imem; ipc_wwan->ipc_imem = ipc_imem;
mutex_init(&ipc_wwan->if_mutex);
/* WWAN core will create a netdev for the default IP MUX channel */ /* WWAN core will create a netdev for the default IP MUX channel */
if (wwan_register_ops(ipc_wwan->dev, &iosm_wwan_ops, ipc_wwan, if (wwan_register_ops(ipc_wwan->dev, &iosm_wwan_ops, ipc_wwan,
IP_MUX_SESSION_DEFAULT)) { IP_MUX_SESSION_DEFAULT)) {
mutex_destroy(&ipc_wwan->if_mutex);
kfree(ipc_wwan); kfree(ipc_wwan);
return NULL; return NULL;
} }
mutex_init(&ipc_wwan->if_mutex);
return ipc_wwan; return ipc_wwan;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment