]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:37:41 +0000 (15:37 -0500)
[ Upstream commit 1c21cf89a66413eb04b2d22c955b7a50edc14dfa ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
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;