net: rose: fix netdev reference changes
authorEric Dumazet <edumazet@google.com>
Fri, 29 Jul 2022 09:12:32 +0000 (09:12 +0000)
committerJakub Kicinski <kuba@kernel.org>
Mon, 1 Aug 2022 18:59:23 +0000 (11:59 -0700)
commit931027820e4dafabc78aff82af59f8c1c4bd3128
tree2ec2f883b9d11050ef6f01a59b0747b761f565c6
parent9936e07eaf5b764ff36c5677644bb5d556fb7e45
net: rose: fix netdev reference changes

Bernard reported that trying to unload rose module would lead
to infamous messages:

unregistered_netdevice: waiting for rose0 to become free. Usage count = xx

This patch solves the issue, by making sure each socket referring to
a netdevice holds a reference count on it, and properly releases it
in rose_release().

rose_dev_first() is also fixed to take a device reference
before leaving the rcu_read_locked section.

Following patch will add ref_tracker annotations to ease
future bug hunting.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: Bernard Pidoux <f6bvp@free.fr>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Tested-by: Bernard Pidoux <f6bvp@free.fr>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/rose/af_rose.c
net/rose/rose_route.c