Bluetooth: AMP: Fix possible NULL dereference
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>
Fri, 5 Oct 2012 13:56:53 +0000 (16:56 +0300)
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>
Sun, 7 Oct 2012 22:14:30 +0000 (06:14 +0800)
Check that link key exist before accessing.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
net/bluetooth/amp.c

index 5dab2d1c7c8284f2896b08cbbc00507684f5a2ff..b6e1c3ac74f1858acd466dea9897a8b47affbad1 100644 (file)
@@ -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);