]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
Bluetooth: btbcm: Fix NULL deref in btbcm_get_board_name()
authorCharles Han <hanchunchao@inspur.com>
Fri, 27 Dec 2024 09:20:46 +0000 (17:20 +0800)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 15 Jan 2025 15:34:27 +0000 (10:34 -0500)
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>
drivers/bluetooth/btbcm.c

index a1153ada74d20689ebf0c4cd0cfdfd6333dfe910..0a60660fc8ce80d6d360ae5e8600f5c3191778ec 100644 (file)
@@ -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 NULL;
+
        strreplace(board_type, '/', '-');
 
        return board_type;