Skip to content

Commit

Permalink
Bluetooth: btbcm: Fix NULL deref in btbcm_get_board_name()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Charles Han authored and tedd-an committed Dec 27, 2024
1 parent a7b2f17 commit d7e9fcc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/bluetooth/btbcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d7e9fcc

Please sign in to comment.