* [PATCH net] net: wwan: iosm: Call mutex_init before locking it
@ 2022-10-01 10:57 Maxim Mikityanskiy
2022-10-03 10:02 ` Kumar, M Chetan
2022-10-03 12:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Maxim Mikityanskiy @ 2022-10-01 10:57 UTC (permalink / raw)
To: M Chetan Kumar, Intel Corporation
Cc: Loic Poulain, Sergey Ryazanov, Johannes Berg, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev,
Maxim Mikityanskiy
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: 83068395bbfc ("net: iosm: create default link via WWAN core")
Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com>
---
drivers/net/wwan/iosm/iosm_ipc_wwan.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wwan/iosm/iosm_ipc_wwan.c b/drivers/net/wwan/iosm/iosm_ipc_wwan.c
index 27151148c782..4712f01a7e33 100644
--- a/drivers/net/wwan/iosm/iosm_ipc_wwan.c
+++ b/drivers/net/wwan/iosm/iosm_ipc_wwan.c
@@ -323,15 +323,16 @@ struct iosm_wwan *ipc_wwan_init(struct iosm_imem *ipc_imem, struct device *dev)
ipc_wwan->dev = dev;
ipc_wwan->ipc_imem = ipc_imem;
+ mutex_init(&ipc_wwan->if_mutex);
+
/* WWAN core will create a netdev for the default IP MUX channel */
if (wwan_register_ops(ipc_wwan->dev, &iosm_wwan_ops, ipc_wwan,
IP_MUX_SESSION_DEFAULT)) {
+ mutex_destroy(&ipc_wwan->if_mutex);
kfree(ipc_wwan);
return NULL;
}
- mutex_init(&ipc_wwan->if_mutex);
-
return ipc_wwan;
}
--
2.37.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH net] net: wwan: iosm: Call mutex_init before locking it
2022-10-01 10:57 [PATCH net] net: wwan: iosm: Call mutex_init before locking it Maxim Mikityanskiy
@ 2022-10-03 10:02 ` Kumar, M Chetan
2022-10-03 12:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Kumar, M Chetan @ 2022-10-03 10:02 UTC (permalink / raw)
To: Maxim Mikityanskiy, linuxwwan
Cc: Loic Poulain, Sergey Ryazanov, Johannes Berg, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev
> -----Original Message-----
> From: Maxim Mikityanskiy <maxtram95@gmail.com>
> Sent: Saturday, October 1, 2022 4:27 PM
> To: Kumar, M Chetan <m.chetan.kumar@intel.com>; linuxwwan
> <linuxwwan@intel.com>
> Cc: Loic Poulain <loic.poulain@linaro.org>; Sergey Ryazanov
> <ryazanov.s.a@gmail.com>; Johannes Berg <johannes@sipsolutions.net>;
> David S. Miller <davem@davemloft.net>; Eric Dumazet
> <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni
> <pabeni@redhat.com>; netdev@vger.kernel.org; Maxim Mikityanskiy
> <maxtram95@gmail.com>
> Subject: [PATCH net] 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: 83068395bbfc ("net: iosm: create default link via WWAN core")
> Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com>
> ---
> drivers/net/wwan/iosm/iosm_ipc_wwan.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wwan/iosm/iosm_ipc_wwan.c
> b/drivers/net/wwan/iosm/iosm_ipc_wwan.c
> index 27151148c782..4712f01a7e33 100644
> --- a/drivers/net/wwan/iosm/iosm_ipc_wwan.c
> +++ b/drivers/net/wwan/iosm/iosm_ipc_wwan.c
> @@ -323,15 +323,16 @@ struct iosm_wwan *ipc_wwan_init(struct
> iosm_imem *ipc_imem, struct device *dev)
> ipc_wwan->dev = dev;
> ipc_wwan->ipc_imem = ipc_imem;
>
> + mutex_init(&ipc_wwan->if_mutex);
> +
> /* WWAN core will create a netdev for the default IP MUX channel */
> if (wwan_register_ops(ipc_wwan->dev, &iosm_wwan_ops,
> ipc_wwan,
> IP_MUX_SESSION_DEFAULT)) {
> + mutex_destroy(&ipc_wwan->if_mutex);
> kfree(ipc_wwan);
> return NULL;
> }
>
> - mutex_init(&ipc_wwan->if_mutex);
> -
> return ipc_wwan;
> }
Reviewed-by: M Chetan Kumar <m.chetan.kumar@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: wwan: iosm: Call mutex_init before locking it
2022-10-01 10:57 [PATCH net] net: wwan: iosm: Call mutex_init before locking it Maxim Mikityanskiy
2022-10-03 10:02 ` Kumar, M Chetan
@ 2022-10-03 12:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-10-03 12:30 UTC (permalink / raw)
To: Maxim Mikityanskiy
Cc: m.chetan.kumar, linuxwwan, loic.poulain, ryazanov.s.a, johannes,
davem, edumazet, kuba, pabeni, netdev
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:
On Sat, 1 Oct 2022 13:57:13 +0300 you wrote:
> 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: 83068395bbfc ("net: iosm: create default link via WWAN core")
> Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com>
>
> [...]
Here is the summary with links:
- [net] net: wwan: iosm: Call mutex_init before locking it
https://git.kernel.org/netdev/net/c/ba0fbdb95da5
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-03 12:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-01 10:57 [PATCH net] net: wwan: iosm: Call mutex_init before locking it Maxim Mikityanskiy
2022-10-03 10:02 ` Kumar, M Chetan
2022-10-03 12:30 ` patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.