]> git.baikalelectronics.ru Git - kernel.git/commit
pinctrl: devicetree: fix null pointer dereferencing in pinctrl_dt_to_map
authorZeng Heng <zengheng4@huawei.com>
Thu, 10 Nov 2022 08:20:56 +0000 (16:20 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Nov 2022 16:42:14 +0000 (17:42 +0100)
commita52189bf956ae7b5427fa1bfe2e64a97fb15eed5
treec3d4eb1edcadf22a6e9e4ab5d9c02e1c821c0d31
parent4e11c44a6e01797a07028a51e4b784cc44336614
pinctrl: devicetree: fix null pointer dereferencing in pinctrl_dt_to_map

[ Upstream commit 112faafcfc7611a6d825b111e35bf6dabc7784e7 ]

Here is the BUG report by KASAN about null pointer dereference:

BUG: KASAN: null-ptr-deref in strcmp+0x2e/0x50
Read of size 1 at addr 0000000000000000 by task python3/2640
Call Trace:
 strcmp
 __of_find_property
 of_find_property
 pinctrl_dt_to_map

kasprintf() would return NULL pointer when kmalloc() fail to allocate.
So directly return ENOMEM, if kasprintf() return NULL pointer.

Fixes: f395ed2c1482 ("pinctrl: core device tree mapping table parsing support")
Signed-off-by: Zeng Heng <zengheng4@huawei.com>
Link: https://lore.kernel.org/r/20221110082056.2014898-1-zengheng4@huawei.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/pinctrl/devicetree.c