[PATCH] Bluetooth: AMP: Fix possible NULL dereference

DORMANTno replies

From: Andrei Emeltchenko <hidden>
Date: 2012-10-04 10:31:07
Subsystem: bluetooth subsystem, the rest · Maintainers: Marcel Holtmann, Luiz Augusto von Dentz, Linus Torvalds

From: Andrei Emeltchenko <redacted>

Check that link key exist before accessing.

Signed-off-by: Andrei Emeltchenko <redacted>
---
 net/bluetooth/amp.c |    4 ++++
 1 file changed, 4 insertions(+)
diff --git a/net/bluetooth/amp.c b/net/bluetooth/amp.c
index c933c72..7e4a1e5 100644
--- a/net/bluetooth/amp.c
+++ b/net/bluetooth/amp.c
@@ -185,6 +185,10 @@ int phylink_gen_key(struct hci_conn *conn, u8 *data, u8 *len, u8 *type)
 	*len = HCI_AMP_LINK_KEY_SIZE;
 
 	key = hci_find_link_key(hdev, &conn->dst);
+	if (!key) {
+		BT_DBG("No Link key for conn %p dst %pMR", conn, &conn->dst);
+		return -EACCES;
+	}
 
 	/* BR/EDR Link Key concatenated together with itself */
 	memcpy(&keybuf[0], key->val, HCI_LINK_KEY_SIZE);
-- 
1.7.9.5
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help