mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 14:42:24 +00:00
ASoC: mediatek: common: handle NULL case in suspend/resume function
When memory allocation for afe->reg_back_up fails, reg_back_up can't
be used.
Keep the suspend/resume flow but skip register backup when
afe->reg_back_up is NULL, in case illegal memory access happens.
Fixes: 283b612429
("ASoC: mediatek: implement mediatek common structure")
Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20210910092613.30188-1-trevor.wu@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
26be23af18
commit
1dd0385226
@ -334,9 +334,11 @@ int mtk_afe_suspend(struct snd_soc_component *component)
|
||||
devm_kcalloc(dev, afe->reg_back_up_list_num,
|
||||
sizeof(unsigned int), GFP_KERNEL);
|
||||
|
||||
for (i = 0; i < afe->reg_back_up_list_num; i++)
|
||||
regmap_read(regmap, afe->reg_back_up_list[i],
|
||||
&afe->reg_back_up[i]);
|
||||
if (afe->reg_back_up) {
|
||||
for (i = 0; i < afe->reg_back_up_list_num; i++)
|
||||
regmap_read(regmap, afe->reg_back_up_list[i],
|
||||
&afe->reg_back_up[i]);
|
||||
}
|
||||
|
||||
afe->suspended = true;
|
||||
afe->runtime_suspend(dev);
|
||||
@ -356,12 +358,13 @@ int mtk_afe_resume(struct snd_soc_component *component)
|
||||
|
||||
afe->runtime_resume(dev);
|
||||
|
||||
if (!afe->reg_back_up)
|
||||
if (!afe->reg_back_up) {
|
||||
dev_dbg(dev, "%s no reg_backup\n", __func__);
|
||||
|
||||
for (i = 0; i < afe->reg_back_up_list_num; i++)
|
||||
mtk_regmap_write(regmap, afe->reg_back_up_list[i],
|
||||
afe->reg_back_up[i]);
|
||||
} else {
|
||||
for (i = 0; i < afe->reg_back_up_list_num; i++)
|
||||
mtk_regmap_write(regmap, afe->reg_back_up_list[i],
|
||||
afe->reg_back_up[i]);
|
||||
}
|
||||
|
||||
afe->suspended = false;
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user