]> git.baikalelectronics.ru Git - kernel.git/commit
pinctrl: ralink: Check for null return of devm_kcalloc
authorWilliam Dean <williamsukatube@gmail.com>
Sun, 10 Jul 2022 15:49:22 +0000 (23:49 +0800)
committerLinus Walleij <linus.walleij@linaro.org>
Mon, 11 Jul 2022 12:40:17 +0000 (14:40 +0200)
commitdc3d521def94d25314a9bdfe7dd81e7ad874ec22
treeeafcb7f951bd7f4bf04bb0097b6e1eaef4a45705
parent0c8b98e40f9d61a6792a879de085b19667a1f51b
pinctrl: ralink: Check for null return of devm_kcalloc

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: 73d07047d7443 ("treewide: devm_kzalloc() -> devm_kcalloc()")
Reported-by: Hacash Robot <hacashRobot@santino.com>
Signed-off-by: William Dean <williamsukatube@gmail.com>
Link: https://lore.kernel.org/r/20220710154922.2610876-1-williamsukatube@163.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/ralink/pinctrl-ralink.c