提交 4d76e94a 编写于 作者: W William Dean 提交者: Zheng Zengkai

pinctrl: ralink: Check for null return of devm_kcalloc

stable inclusion
from stable-v5.10.134
commit 5694b162f275fb9a9f89422701b2b963be11e496
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5ZVR7

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

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

[ Upstream commit c3b821e8 ]

Because of the possible failure of the allocation, data->domains might
be NULL pointer and will cause the dereference of the NULL pointer
later.
Therefore, it might be better to check it and directly return -ENOMEM
without releasing data manually if fails, because the comment of the
devm_kmalloc() says "Memory allocated with this function is
automatically freed on driver detach.".

Fixes: a86854d0 ("treewide: devm_kzalloc() -> devm_kcalloc()")
Reported-by: NHacash Robot <hacashRobot@santino.com>
Signed-off-by: NWilliam Dean <williamsukatube@gmail.com>
Link: https://lore.kernel.org/r/20220710154922.2610876-1-williamsukatube@163.comSigned-off-by: NLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 11890294
...@@ -267,6 +267,8 @@ static int rt2880_pinmux_pins(struct rt2880_priv *p) ...@@ -267,6 +267,8 @@ static int rt2880_pinmux_pins(struct rt2880_priv *p)
p->func[i]->pin_count, p->func[i]->pin_count,
sizeof(int), sizeof(int),
GFP_KERNEL); GFP_KERNEL);
if (!p->func[i]->pins)
return -ENOMEM;
for (j = 0; j < p->func[i]->pin_count; j++) for (j = 0; j < p->func[i]->pin_count; j++)
p->func[i]->pins[j] = p->func[i]->pin_first + j; p->func[i]->pins[j] = p->func[i]->pin_first + j;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册