All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btbcm: Fix NULL deref in btbcm_get_board_name()
@ 2024-12-27  9:20 Charles Han
  2024-12-27  9:54 ` bluez.test.bot
  2025-01-09 16:17 ` [PATCH] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ 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 related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-01-09 16:16 UTC | newest]

Thread overview: 3+ 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
2024-12-27  9:54 ` bluez.test.bot
2025-01-09 16:17 ` [PATCH] " patchwork-bot+bluetooth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.