]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net: Fix netdev_run_todo dead-lock
authorHerbert Xu <herbert@gondor.apana.org.au>
Tue, 7 Oct 2008 22:50:03 +0000 (15:50 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 10 Nov 2008 18:50:07 +0000 (10:50 -0800)
commit5a150aee377ec6d080ce44d57935e3972136117a
tree88149a93bea1f9cb068917772d55a98154a0a57e
parent666b1a208ee219ea395c3321cd55d097dd77de95
net: Fix netdev_run_todo dead-lock

[ Upstream commit 58ec3b4db9eb5a28e3aec5f407a54e28f7039c19 ]

Benjamin Thery tracked down a bug that explains many instances
of the error

unregister_netdevice: waiting for %s to become free. Usage count = %d

It turns out that netdev_run_todo can dead-lock with itself if
a second instance of it is run in a thread that will then free
a reference to the device waited on by the first instance.

The problem is really quite silly.  We were trying to create
parallelism where none was required.  As netdev_run_todo always
follows a RTNL section, and that todo tasks can only be added
with the RTNL held, by definition you should only need to wait
for the very ones that you've added and be done with it.

There is no need for a second mutex or spinlock.

This is exactly what the following patch does.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
net/core/dev.c
net/core/rtnetlink.c