Commit 19593695 authored by Zeng Heng's avatar Zeng Heng Committed by sanglipeng
Browse files

pinctrl: devicetree: fix null pointer dereferencing in pinctrl_dt_to_map

stable inclusion
from stable-v5.10.156
commit 777430aa4ddccaa5accec6db90ffc1d47f00d471
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7MCG1

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=777430aa4ddccaa5accec6db90ffc1d47f00d471



--------------------------------

[ Upstream commit 91d5c506 ]

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: 57291ce2 ("pinctrl: core device tree mapping table parsing support")
Signed-off-by: default avatarZeng Heng <zengheng4@huawei.com>
Link: https://lore.kernel.org/r/20221110082056.2014898-1-zengheng4@huawei.com


Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarsanglipeng <sanglipeng1@jd.com>
parent 593944d0
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment