Skip to content

Commit

Permalink
ASoC: qcom: Add checks for devm_kcalloc
Browse files Browse the repository at this point in the history
[ Upstream commit 1bf5ee9 ]

As the devm_kcalloc may return NULL, the return value needs to be checked
to avoid NULL poineter dereference.

Fixes: 24caf8d ("ASoC: qcom: lpass-sc7180: Add platform driver for lpass audio")
Signed-off-by: Yuan Can <yuancan@huawei.com>
Link: https://lore.kernel.org/r/20221124140510.63468-1-yuancan@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Yuan Can authored and gregkh committed Dec 31, 2022
1 parent 1643764 commit f849c11
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sound/soc/qcom/lpass-sc7180.c
Expand Up @@ -131,6 +131,9 @@ static int sc7180_lpass_init(struct platform_device *pdev)

drvdata->clks = devm_kcalloc(dev, variant->num_clks,
sizeof(*drvdata->clks), GFP_KERNEL);
if (!drvdata->clks)
return -ENOMEM;

drvdata->num_clks = variant->num_clks;

for (i = 0; i < drvdata->num_clks; i++)
Expand Down

0 comments on commit f849c11

Please sign in to comment.