Skip to contentSkip to conversation

Bluetooth: hci_ll: Fix firmware leak on error path

PATCH Superseded Anas Iqbal 1 participant 1 message Mar 15 Bluetooth drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Anas Iqbal

author
#0 lore raw

PATCH 1/1 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 371805522f87 ("bluetooth: hci_uart: add LL protocol serdev driver support")

---
v2:
- Fix grammar ("content is")
- Add Fixes tag
- Add Reviewed-by tag from Paul Menzel

---
 drivers/bluetooth/hci_ll.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/bluetooth/hci_ll.c +2 -0
index 91acf24f1ef5..91c96ad12342 100644
@@ -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;
Signature · 1 line
2.43.0