Skip to content

Commit 91d5c50

Browse files
henryZeLinus Walleij
authored andcommitted
pinctrl: devicetree: fix null pointer dereferencing in pinctrl_dt_to_map
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: 57291ce ("pinctrl: core device tree mapping table parsing support") Signed-off-by: Zeng Heng <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent fed74d7 commit 91d5c50

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/pinctrl/devicetree.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ int pinctrl_dt_to_map(struct pinctrl *p, struct pinctrl_dev *pctldev)
220220
for (state = 0; ; state++) {
221221
/* Retrieve the pinctrl-* property */
222222
propname = kasprintf(GFP_KERNEL, "pinctrl-%d", state);
223+
if (!propname)
224+
return -ENOMEM;
223225
prop = of_find_property(np, propname, &size);
224226
kfree(propname);
225227
if (!prop) {

0 commit comments

Comments
 (0)