]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
Bluetooth: btrtl: Fix memory leak in rtlbt_parse_firmware_v2()
authorAbdun Nihaal <nihaal@cse.iitm.ac.in>
Tue, 28 Oct 2025 17:56:30 +0000 (23:26 +0530)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fri, 31 Oct 2025 16:42:47 +0000 (12:42 -0400)
The memory allocated for ptr using kvmalloc() is not freed on the last
error path. Fix that by freeing it on that error path.

Fixes: 9a24ce5e29b1 ("Bluetooth: btrtl: Firmware format v2 support")
Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
drivers/bluetooth/btrtl.c

index 6abd962502e368442ce5a1a029daa08fd6cbb930..1d4a7887abccfb306dc4a3ac469bfca1e6d2d7b8 100644 (file)
@@ -625,8 +625,10 @@ static int rtlbt_parse_firmware_v2(struct hci_dev *hdev,
                len += entry->len;
        }
 
-       if (!len)
+       if (!len) {
+               kvfree(ptr);
                return -EPERM;
+       }
 
        *_buf = ptr;
        return len;