Bluetooth: btrtl: fix incorrect skb allocation failure check
authorColin Ian King <colin.king@canonical.com>
Tue, 10 Nov 2020 12:39:15 +0000 (12:39 +0000)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 11 Nov 2020 10:53:56 +0000 (11:53 +0100)
Currently the check for a failed bt_skb_alloc allocation is incorrectly
checking using IS_ERR and this can lead to a null pointer dereference. Fix
this by checking for a null pointer return using the !skb idiom.

Addresses-Coverity: ("Dereference null return")
Fixes: 1996d9cad6ad ("Bluetooth: btrtl: Ask 8821C to drop old firmware")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
drivers/bluetooth/btrtl.c

index e47736a12f77067b17ca3c2e31be61783a9894b1..a4f7cace66b067f987e7f90539fd04c52b09f34d 100644 (file)
@@ -581,7 +581,7 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
                cmd[1] = opcode >> 8;
 
                skb = bt_skb_alloc(sizeof(cmd), GFP_KERNEL);
-               if (IS_ERR(skb))
+               if (!skb)
                        goto out_free;
 
                skb_put_data(skb, cmd, sizeof(cmd));