ASoC: mediatek: mt8365: check suspend backup allocation
Subsystems (3)
PATCH 1/1 ASoC: mediatek: mt8365: check suspend backup allocation
mt8365_afe_suspend() lazily allocates the register backup array and then stores register values into it. If devm_kcalloc() fails, the suspend path dereferences afe->reg_back_up in the backup loop.
Check the allocation result before using the array. Disable the main clock before returning so the error path balances the clock enable at the start of suspend.
Signed-off-by Ruoyu Wang <[email protected]>
--- sound/soc/mediatek/mt8365/mt8365-afe-pcm.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/soc/mediatek/mt8365/mt8365-afe-pcm.c +4 -0
@@ -1978,6 +1978,10 @@ static int mt8365_afe_suspend(struct device *dev) afe->reg_back_up =devm_kcalloc (dev, afe->reg_back_up_list_num,sizeof (unsigned int ),GFP_KERNEL ); +if (!afe->reg_back_up) { +mt8365_afe_disable_main_clk (afe); +return -ENOMEM ; + }for (i =0 ; i < afe->reg_back_up_list_num; i++) regmap_read(regmap, afe->reg_back_up_list[i],
Signature · 1 line
2.34.1