Thread (3 messages) 3 messages, 3 authors, 2016-01-21

[PATCH] Bluetooth: add hdev check to avoid passing null pointer

flat view
STALE3926d

From: Fugang Duan <hidden>
Date: 2016-01-21 04:45:58
Subsystem: bluetooth subsystem, the rest · Maintainers: Marcel Holtmann, Luiz Augusto von Dentz, Linus Torvalds

Function hci_mgmt_cmd() may pass hdev with null pointer to hci_mgmt_handler->func()
like below code:
	err = handler->func(sk, hdev, cp, len);

Add hdev check to avoid passing null pointer.

Signed-off-by: Fugang Duan <redacted>
---
 net/bluetooth/hci_sock.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 1298d72..7fdfc80 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -1186,6 +1186,8 @@ static int hci_mgmt_cmd(struct hci_mgmt_chan *chan, struct sock *sk,
 
 	if (hdev && chan->hdev_init)
 		chan->hdev_init(sk, hdev);
+	else if (!hdev)
+		goto done;
 
 	cp = buf + sizeof(*hdr);
 
-- 
1.9.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help