]> git.baikalelectronics.ru Git - kernel.git/commit
tun: Fix device unregister race
authorHerbert Xu <herbert@gondor.apana.org.au>
Thu, 2 Jul 2009 23:03:55 +0000 (23:03 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 6 Jul 2009 01:03:18 +0000 (18:03 -0700)
commit7ee0e6d3e92fecc14b4766691572892dfa5d339f
tree49449c308390dc319fc83378dbd357041c7f27ea
parent8f468a4e349aed2685b463f1922517c2e7e97bea
tun: Fix device unregister race

It is currently possible for an asynchronous device unregister
to cause the same tun device to be unregistered twice.  This
is because the unregister in tun_chr_close only checks whether
__tun_get(tfile) != NULL.  This however has nothing to do with
whether the device has already been unregistered.  All it tells
you is whether __tun_detach has been called.

This patch fixes this by using the most obvious thing to test
whether the device has been unregistered.

It also moves __tun_detach outside of rtnl_unlock since nothing
that it does requires that lock.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/tun.c