net/x25: fix use-after-free in x25_device_event()
[GitHub/moto-9609/android_kernel_motorola_exynos9610.git] / net / x25 / af_x25.c
index 47f600564f2454907f0436c7ac01e6f4bfccece5..716d53b683e0871656f0b3183a32bbf55e1614db 100644 (file)
@@ -812,8 +812,12 @@ static int x25_connect(struct socket *sock, struct sockaddr *uaddr,
        sock->state = SS_CONNECTED;
        rc = 0;
 out_put_neigh:
-       if (rc)
+       if (rc) {
+               read_lock_bh(&x25_list_lock);
                x25_neigh_put(x25->neighbour);
+               x25->neighbour = NULL;
+               read_unlock_bh(&x25_list_lock);
+       }
 out_put_route:
        x25_route_put(rt);
 out: