Skip to content

Commit b88655b

Browse files
Charles HanVudentz
authored andcommitted
Bluetooth: btbcm: Fix NULL deref in btbcm_get_board_name()
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 <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 30209ae commit b88655b

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)