Skip to content

Commit 74af8b9

Browse files
Charles Hangregkh
Charles Han
authored andcommitted
Bluetooth: btbcm: Fix NULL deref in btbcm_get_board_name()
[ Upstream commit b88655b ] 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: f9183ea ("Bluetooth: btbcm: Use devm_kstrdup()") Signed-off-by: Charles Han <hanchunchao@inspur.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent aef27b5 commit 74af8b9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/bluetooth/btbcm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,9 @@ static const char *btbcm_get_board_name(struct device *dev)
553553

554554
/* get rid of any '/' in the compatible string */
555555
board_type = devm_kstrdup(dev, tmp, GFP_KERNEL);
556+
if (!board_type)
557+
return NULL;
558+
556559
strreplace(board_type, '/', '-');
557560

558561
return board_type;

0 commit comments

Comments
 (0)