mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btrtl: Fix memory leak in rtlbt_parse_firmware_v2()
@ 2025-10-28 17:56 Abdun Nihaal
  2025-10-28 21:30 ` patchwork-bot+bluetooth
  0 siblings, 1 reply; 2+ messages in thread
From: Abdun Nihaal @ 2025-10-28 17:56 UTC (permalink / raw)
  To: marcel; +Cc: Abdun Nihaal, luiz.dentz, linux-bluetooth, linux-kernel

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>
---
Compile tested only. Issue found using static analysis.

 drivers/bluetooth/btrtl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
index 6abd962502e3..1d4a7887abcc 100644
--- a/drivers/bluetooth/btrtl.c
+++ b/drivers/bluetooth/btrtl.c
@@ -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;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Bluetooth: btrtl: Fix memory leak in rtlbt_parse_firmware_v2()
  2025-10-28 17:56 [PATCH] Bluetooth: btrtl: Fix memory leak in rtlbt_parse_firmware_v2() Abdun Nihaal
@ 2025-10-28 21:30 ` patchwork-bot+bluetooth
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+bluetooth @ 2025-10-28 21:30 UTC (permalink / raw)
  To: Abdun Nihaal; +Cc: marcel, luiz.dentz, linux-bluetooth, linux-kernel

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Tue, 28 Oct 2025 23:26:30 +0530 you wrote:
> 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>
> ---
> Compile tested only. Issue found using static analysis.
> 
> [...]

Here is the summary with links:
  - Bluetooth: btrtl: Fix memory leak in rtlbt_parse_firmware_v2()
    https://git.kernel.org/bluetooth/bluetooth-next/c/4a3855790fba

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-10-28 21:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-28 17:56 [PATCH] Bluetooth: btrtl: Fix memory leak in rtlbt_parse_firmware_v2() Abdun Nihaal
2025-10-28 21:30 ` patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®