]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Bluetooth: hci_ll: Fix firmware leak on error path
authorAnas Iqbal <mohd.abd.6602@gmail.com>
Sun, 15 Mar 2026 10:51:37 +0000 (10:51 +0000)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 19 Mar 2026 18:43:43 +0000 (14:43 -0400)
Smatch reports:

drivers/bluetooth/hci_ll.c:587 download_firmware() warn:
'fw' from request_firmware() not released on lines: 544.

In download_firmware(), if request_firmware() succeeds but the returned
firmware content is invalid (no data or zero size), the function returns
without releasing the firmware, resulting in a resource leak.

Fix this by calling release_firmware() before returning when
request_firmware() succeeded but the firmware content is invalid.

Fixes: 371805522f87 ("bluetooth: hci_uart: add LL protocol serdev driver support")
Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Signed-off-by: Anas Iqbal <mohd.abd.6602@gmail.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
drivers/bluetooth/hci_ll.c

index 91acf24f1ef5449e17b003bbbfd5a39ddd7170e9..91c96ad123422193c60fe4daf6a96aa0e1bd0b59 100644 (file)
@@ -541,6 +541,8 @@ static int download_firmware(struct ll_device *lldev)
        if (err || !fw->data || !fw->size) {
                bt_dev_err(lldev->hu.hdev, "request_firmware failed(errno %d) for %s",
                           err, bts_scr_name);
+               if (!err)
+                       release_firmware(fw);
                return -EINVAL;
        }
        ptr = (void *)fw->data;