netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] netdevsim: fix unbalaced locking in nsim_create()
@ 2020-07-21 14:51 Taehee Yoo
  2020-07-21 19:27 ` Jakub Kicinski
  2020-07-21 23:09 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Taehee Yoo @ 2020-07-21 14:51 UTC (permalink / raw)
  To: davem, kuba, netdev; +Cc: jiri, ap420073

In the nsim_create(), rtnl_lock() is called before nsim_bpf_init().
If nsim_bpf_init() is failed, rtnl_unlock() should be called,
but it isn't called.
So, unbalanced locking would occur.

Fixes: e05b2d141fef ("netdevsim: move netdev creation/destruction to dev probe")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
---

v1->v2:
 - Change error path label name.

 drivers/net/netdevsim/netdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c
index 2908e0a0d6e1..23950e7a0f81 100644
--- a/drivers/net/netdevsim/netdev.c
+++ b/drivers/net/netdevsim/netdev.c
@@ -302,7 +302,7 @@ nsim_create(struct nsim_dev *nsim_dev, struct nsim_dev_port *nsim_dev_port)
 	rtnl_lock();
 	err = nsim_bpf_init(ns);
 	if (err)
-		goto err_free_netdev;
+		goto err_rtnl_unlock;
 
 	nsim_ipsec_init(ns);
 
@@ -316,8 +316,8 @@ nsim_create(struct nsim_dev *nsim_dev, struct nsim_dev_port *nsim_dev_port)
 err_ipsec_teardown:
 	nsim_ipsec_teardown(ns);
 	nsim_bpf_uninit(ns);
+err_rtnl_unlock:
 	rtnl_unlock();
-err_free_netdev:
 	free_netdev(dev);
 	return ERR_PTR(err);
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] netdevsim: fix unbalaced locking in nsim_create()
  2020-07-21 14:51 [PATCH net v2] netdevsim: fix unbalaced locking in nsim_create() Taehee Yoo
@ 2020-07-21 19:27 ` Jakub Kicinski
  2020-07-21 23:09 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2020-07-21 19:27 UTC (permalink / raw)
  To: Taehee Yoo; +Cc: davem, netdev, jiri

On Tue, 21 Jul 2020 14:51:50 +0000 Taehee Yoo wrote:
> In the nsim_create(), rtnl_lock() is called before nsim_bpf_init().
> If nsim_bpf_init() is failed, rtnl_unlock() should be called,
> but it isn't called.
> So, unbalanced locking would occur.
> 
> Fixes: e05b2d141fef ("netdevsim: move netdev creation/destruction to dev probe")
> Signed-off-by: Taehee Yoo <ap420073@gmail.com>

Reviewed-by: Jakub Kicinski <kuba@kernel.org>

Thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] netdevsim: fix unbalaced locking in nsim_create()
  2020-07-21 14:51 [PATCH net v2] netdevsim: fix unbalaced locking in nsim_create() Taehee Yoo
  2020-07-21 19:27 ` Jakub Kicinski
@ 2020-07-21 23:09 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2020-07-21 23:09 UTC (permalink / raw)
  To: ap420073; +Cc: kuba, netdev, jiri

From: Taehee Yoo <ap420073@gmail.com>
Date: Tue, 21 Jul 2020 14:51:50 +0000

> In the nsim_create(), rtnl_lock() is called before nsim_bpf_init().
> If nsim_bpf_init() is failed, rtnl_unlock() should be called,
> but it isn't called.
> So, unbalanced locking would occur.
> 
> Fixes: e05b2d141fef ("netdevsim: move netdev creation/destruction to dev probe")
> Signed-off-by: Taehee Yoo <ap420073@gmail.com>

Applied and queued up for -stable, thank you.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-21 23:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-21 14:51 [PATCH net v2] netdevsim: fix unbalaced locking in nsim_create() Taehee Yoo
2020-07-21 19:27 ` Jakub Kicinski
2020-07-21 23:09 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).