ASoC: qcom: Add checks for devm_kcalloc
authorYuan Can <yuancan@huawei.com>
Thu, 24 Nov 2022 14:05:10 +0000 (14:05 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:32:15 +0000 (13:32 +0100)
[ Upstream commit 1bf5ee979076ceb121ee51c95197d890b1cee7f4 ]

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

Fixes: 24caf8d9eb10 ("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>
sound/soc/qcom/lpass-sc7180.c

index 77a556b27cf09678e1aeb206a47be3c832e8edfb..24a1c121cb2e9c65d185cd6c98be4f83db2bd514 100644 (file)
@@ -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++)