Commit a467f2f8 authored by Colin Ian King's avatar Colin Ian King Committed by Mark Brown

ASoC: qcom: add missing out of memory check on drvdata->clks allocation

Currently drvdata->clks is not being checked for an allocation failure,
leading to potential null pointer dereferencing. Fix this by adding a
check and returning -ENOMEM if an error occurred.

Fixes: 1220f6a7 ("ASoC: qcom: Add common array to initialize soc based core clocks")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Reviewed-by: default avatarRohit kumar <rohitkr@codeaurora.org>
Addresses-Coverity: ("Dereference null return value")
Link: https://lore.kernel.org/r/20200819160103.164893-1-colin.king@canonical.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 1eb62936
......@@ -168,6 +168,8 @@ static int apq8016_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++)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment