mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btbcm: Fix NULL deref in btbcm_get_board_name()
@ 2024-12-27  9:20 Charles Han
  2025-01-09 16:17 ` patchwork-bot+bluetooth
  0 siblings, 1 reply; 2+ messages in thread
From: Charles Han @ 2024-12-27  9:20 UTC (permalink / raw)
  To: marcel, luiz.dentz, christophe.jaillet
  Cc: linux-bluetooth, linux-kernel, Charles Han

devm_kstrdup() can return a NULL pointer on failure,but this
returned value in btbcm_get_board_name() is not checked.
Add NULL check in btbcm_get_board_name(), to handle kernel NULL
pointer dereference error.

Fixes: f9183eaad915 ("Bluetooth: btbcm: Use devm_kstrdup()")
Signed-off-by: Charles Han <hanchunchao@inspur.com>
---
 drivers/bluetooth/btbcm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index a1153ada74d2..d7f3ccf5f594 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -553,6 +553,9 @@ static const char *btbcm_get_board_name(struct device *dev)
 
 	/* get rid of any '/' in the compatible string */
 	board_type = devm_kstrdup(dev, tmp, GFP_KERNEL);
+	if (!board_type)
+		return -ENOMEM;
+
 	strreplace(board_type, '/', '-');
 
 	return board_type;
-- 
2.31.1


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

* Re: [PATCH] Bluetooth: btbcm: Fix NULL deref in btbcm_get_board_name()
  2024-12-27  9:20 [PATCH] Bluetooth: btbcm: Fix NULL deref in btbcm_get_board_name() Charles Han
@ 2025-01-09 16:17 ` patchwork-bot+bluetooth
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+bluetooth @ 2025-01-09 16:17 UTC (permalink / raw)
  To: Charles Han
  Cc: marcel, luiz.dentz, christophe.jaillet, 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 Fri, 27 Dec 2024 17:20:46 +0800 you wrote:
> devm_kstrdup() can return a NULL pointer on failure,but this
> returned value in btbcm_get_board_name() is not checked.
> Add NULL check in btbcm_get_board_name(), to handle kernel NULL
> pointer dereference error.
> 
> Fixes: f9183eaad915 ("Bluetooth: btbcm: Use devm_kstrdup()")
> Signed-off-by: Charles Han <hanchunchao@inspur.com>
> 
> [...]

Here is the summary with links:
  - Bluetooth: btbcm: Fix NULL deref in btbcm_get_board_name()
    https://git.kernel.org/bluetooth/bluetooth-next/c/52d2af107592

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-01-09 16:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-27  9:20 [PATCH] Bluetooth: btbcm: Fix NULL deref in btbcm_get_board_name() Charles Han
2025-01-09 16:17 ` 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®