diff mbox series

L2CAP: Fix null-ptr-deref in l2cap_sock_set_shutdown_cb

Message ID 20230119020406.3900747-1-iam@sung-woo.kim
State Superseded
Headers show
Series L2CAP: Fix null-ptr-deref in l2cap_sock_set_shutdown_cb | expand

Commit Message

Sungwoo Kim Jan. 19, 2023, 2:04 a.m. UTC
Fix a critical typo on the prev patch - Sorry!

Signed-off-by: Sungwoo Kim <iam@sung-woo.kim>
---
 net/bluetooth/l2cap_sock.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index ca8f07f35..b9381d45d 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1681,9 +1681,11 @@  static void l2cap_sock_set_shutdown_cb(struct l2cap_chan *chan)
 {
 	struct sock *sk = chan->data;
 
-	lock_sock(sk);
-	sk->sk_shutdown = SHUTDOWN_MASK;
-	release_sock(sk);
+	if (sk) {
+		lock_sock(sk);
+		sk->sk_shutdown = SHUTDOWN_MASK;
+		release_sock(sk);
+	}
 }
 
 static long l2cap_sock_get_sndtimeo_cb(struct l2cap_chan *chan)