Skip to content

Commit ba0fbdb

Browse files
gentoo-rootdavem330
authored andcommitted
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: 8306839 ("net: iosm: create default link via WWAN core") Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com> Reviewed-by: M Chetan Kumar <m.chetan.kumar@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 12aece8 commit ba0fbdb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/net/wwan/iosm/iosm_ipc_wwan.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,16 @@ struct iosm_wwan *ipc_wwan_init(struct iosm_imem *ipc_imem, struct device *dev)
323323
ipc_wwan->dev = dev;
324324
ipc_wwan->ipc_imem = ipc_imem;
325325

326+
mutex_init(&ipc_wwan->if_mutex);
327+
326328
/* WWAN core will create a netdev for the default IP MUX channel */
327329
if (wwan_register_ops(ipc_wwan->dev, &iosm_wwan_ops, ipc_wwan,
328330
IP_MUX_SESSION_DEFAULT)) {
331+
mutex_destroy(&ipc_wwan->if_mutex);
329332
kfree(ipc_wwan);
330333
return NULL;
331334
}
332335

333-
mutex_init(&ipc_wwan->if_mutex);
334-
335336
return ipc_wwan;
336337
}
337338

0 commit comments

Comments
 (0)