Bluetooth: btbcm: Fix NULL deref in btbcm_get_board_name()
BugLink: https://bugs.launchpad.net/bugs/2111953 [ Upstream commit b88655bc6593c6a7fdc1248b212d17e581c4334e ] 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> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Manuel Diewald <manuel.diewald@canonical.com> Signed-off-by: Mehmet Basaran <mehmet.basaran@canonical.com>
This commit is contained in:
committed by
Mehmet Basaran
parent
5ff0d6794c
commit
b6eaff8801
@@ -555,6 +555,9 @@ static const char *btbcm_get_board_name(struct device *dev)
|
||||
/* get rid of any '/' in the compatible string */
|
||||
len = strlen(tmp) + 1;
|
||||
board_type = devm_kzalloc(dev, len, GFP_KERNEL);
|
||||
if (!board_type)
|
||||
return NULL;
|
||||
|
||||
strscpy(board_type, tmp, len);
|
||||
for (i = 0; i < len; i++) {
|
||||
if (board_type[i] == '/')
|
||||
|
||||
Reference in New Issue
Block a user