Skip to content

Commit

Permalink
soc: ti: ti_sci_pm_domains: Check for null return of devm_kcalloc
Browse files Browse the repository at this point in the history
[ Upstream commit ba56291 ]

The allocation funciton devm_kcalloc may fail and return a null pointer,
which would cause a null-pointer dereference later.
It might be better to check it and directly return -ENOMEM just like the
usage of devm_kcalloc in previous code.

Signed-off-by: QintaoShen <unSimple1993@163.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
Link: https://lore.kernel.org/r/1648107843-29077-1-git-send-email-unSimple1993@163.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
shenqtao authored and gregkh committed Jun 9, 2022
1 parent 0f9091f commit 05efc45
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/soc/ti/ti_sci_pm_domains.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ static int ti_sci_pm_domain_probe(struct platform_device *pdev)
devm_kcalloc(dev, max_id + 1,
sizeof(*pd_provider->data.domains),
GFP_KERNEL);
if (!pd_provider->data.domains)
return -ENOMEM;

pd_provider->data.num_domains = max_id + 1;
pd_provider->data.xlate = ti_sci_pd_xlate;
Expand Down

0 comments on commit 05efc45

Please sign in to comment.