Commit 2c9d8e01 authored by Taehee Yoo's avatar Taehee Yoo Committed by David S. Miller

netdevsim: fix unbalaced locking in nsim_create()

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: e05b2d14 ("netdevsim: move netdev creation/destruction to dev probe")
Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
Reviewed-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3506b2f4
...@@ -302,7 +302,7 @@ nsim_create(struct nsim_dev *nsim_dev, struct nsim_dev_port *nsim_dev_port) ...@@ -302,7 +302,7 @@ nsim_create(struct nsim_dev *nsim_dev, struct nsim_dev_port *nsim_dev_port)
rtnl_lock(); rtnl_lock();
err = nsim_bpf_init(ns); err = nsim_bpf_init(ns);
if (err) if (err)
goto err_free_netdev; goto err_rtnl_unlock;
nsim_ipsec_init(ns); nsim_ipsec_init(ns);
...@@ -316,8 +316,8 @@ nsim_create(struct nsim_dev *nsim_dev, struct nsim_dev_port *nsim_dev_port) ...@@ -316,8 +316,8 @@ nsim_create(struct nsim_dev *nsim_dev, struct nsim_dev_port *nsim_dev_port)
err_ipsec_teardown: err_ipsec_teardown:
nsim_ipsec_teardown(ns); nsim_ipsec_teardown(ns);
nsim_bpf_uninit(ns); nsim_bpf_uninit(ns);
err_rtnl_unlock:
rtnl_unlock(); rtnl_unlock();
err_free_netdev:
free_netdev(dev); free_netdev(dev);
return ERR_PTR(err); return ERR_PTR(err);
} }
......
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