]> 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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 29 Jul 2022 15:14:10 +0000 (17:14 +0200)
commitb51454b10949bd02f4e85dafba1c19b5bc0540dc
tree7eba0e2ecd32e48e338f602ed07f03fe13ac01ff
parent9ab3c876dbd1b5c5120c27d4d42c2cac38a3e158
pinctrl: ralink: Check for null return of devm_kcalloc

[ Upstream commit 8d8a4a817fae7e9fe19f85a748bce22a99be0090 ]

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: 2d8d0d782a191 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c