soc: qcom: rpmpd: Check for null return of devm_kcalloc
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Fri, 31 Dec 2021 09:44:19 +0000 (17:44 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 12:23:15 +0000 (14:23 +0200)
commit724376c30af5a57686b223dbcd6188e07d2a1de2
tree384b3b5e7f3b1e108ba25c52c882a3ef4943e497
parentd761d62022bb384cda8baa2c9ea4141ed02b7ac2
soc: qcom: rpmpd: Check for null return of devm_kcalloc

[ Upstream commit 5a811126d38f9767a20cc271b34db7c8efc5a46c ]

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: bbe3a66c3f5a ("soc: qcom: rpmpd: Add a Power domain driver to model corners")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20211231094419.1941054-1-jiasheng@iscas.ac.cn
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/soc/qcom/rpmpd.c