Skip to content

Commit 31148a7

Browse files
iqbalcodes6602Vudentz
authored andcommitted
Bluetooth: hci_ll: Fix firmware leak on error path
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: 3718055 ("bluetooth: hci_uart: add LL protocol serdev driver support") Reviewed-by: Paul Menzel <[email protected]> Signed-off-by: Anas Iqbal <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent b6807cf commit 31148a7

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/bluetooth/hci_ll.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,8 @@ static int download_firmware(struct ll_device *lldev)
541541
if (err || !fw->data || !fw->size) {
542542
bt_dev_err(lldev->hu.hdev, "request_firmware failed(errno %d) for %s",
543543
err, bts_scr_name);
544+
if (!err)
545+
release_firmware(fw);
544546
return -EINVAL;
545547
}
546548
ptr = (void *)fw->data;

0 commit comments

Comments
 (0)