Commit 31148a7b authored by Anas Iqbal's avatar Anas Iqbal Committed by Luiz Augusto von Dentz
Browse files

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: 37180552 ("bluetooth: hci_uart: add LL protocol serdev driver support")
Reviewed-by: default avatarPaul Menzel <pmenzel@molgen.mpg.de>
Signed-off-by: default avatarAnas Iqbal <mohd.abd.6602@gmail.com>
Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
parent b6807cfc
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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;