From 079db0c6e3854b3af9808268f3b884fa48ed0034 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Fri, 5 Oct 2012 16:56:53 +0300 Subject: [PATCH] Bluetooth: AMP: Fix possible NULL dereference Check that link key exist before accessing. Signed-off-by: Andrei Emeltchenko Signed-off-by: Gustavo Padovan --- net/bluetooth/amp.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/bluetooth/amp.c b/net/bluetooth/amp.c index 5dab2d1c7c82..b6e1c3ac74f1 100644 --- a/net/bluetooth/amp.c +++ b/net/bluetooth/amp.c @@ -184,6 +184,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); -- 2.39.5