6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Junjie Cao When a device goes down, nr_rt_device_down() clears the routes that use this device. However, it fails to drop the per-route reference to the neighbour (nr_neigh): neither nr_neigh->count nor its refcount is decremented when the route is removed. Mirror the behaviour of nr_dec_obs() / nr_del_node() by decrementing nr_neigh->count and calling nr_neigh_put(), so that the neighbour reference is properly released when a device goes down. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Junjie Cao [F6BVP: rebased on the single nr_route_lock; the list reference is still dropped last by nr_remove_neigh_locked(), so the neighbour stays valid while its routes are removed.] Signed-off-by: Bernard Pidoux (cherry picked from commit b0f6830b24b75618e299c8e5451367e8742272da) Signed-off-by: Sasha Levin --- net/netrom/nr_route.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/netrom/nr_route.c b/net/netrom/nr_route.c index 10294cf068f8a..67d9ed0006b40 100644 --- a/net/netrom/nr_route.c +++ b/net/netrom/nr_route.c @@ -526,6 +526,9 @@ void nr_rt_device_down(struct net_device *dev) nr_node_for_each_safe(t, node2t, &nr_node_list) { for (i = 0; i < t->count; i++) { if (t->routes[i].neighbour == s) { + s->count--; + nr_neigh_put(s); + t->count--; switch (i) { -- 2.53.0