Skip to contentSkip to conversation

firmware: cs_dsp: Fix memory leak on cs_dsp_power_up() error path

PATCH In review Richard Fitzgerald 2 participants 3 messages Nov 4

Subsystems (2)
lore
Share & tools
lore

Richard Fitzgerald

author maintainer
#0 lore raw

PATCH 1/1 firmware: cs_dsp: Fix memory leak on cs_dsp_power_up() error path

If cs_dsp_power_up() fails on or after cs_dsp_load() mark the controls disabled and free the alg regions.

Fixes f6bc909e7673c ("firmware: cs_dsp: add driver to support firmware loading on Cirrus Logic DSPs")
---
 drivers/firmware/cirrus/cs_dsp.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/firmware/cirrus/cs_dsp.c +6 -0
index 844c68036975f..4dcce87685d33 100644
@@ -2793,6 +2793,7 @@ int cs_dsp_power_up(struct cs_dsp *dsp,
 		    const struct firmware *coeff_firmware, const char *coeff_filename,
 		    const char *fw_name)
 {
+	struct cs_dsp_coeff_ctl *ctl;
 	int ret;
 
 	mutex_lock(&dsp->pwr_lock);
@@ -2838,6 +2839,11 @@ int cs_dsp_power_up(struct cs_dsp *dsp,
 
 	return 0;
 err_ena:
+	list_for_each_entry(ctl, &dsp->ctl_list, list)
+		ctl->enabled = 0;
+
+	cs_dsp_free_alg_regions(dsp);
+
 	if (dsp->ops->disable_core)
 		dsp->ops->disable_core(dsp);
 err_mem:
Signature · 1 line
2.47.3
#1 lore raw

drivers/firmware/cirrus/cs_dsp.c int cs_dsp_power_up(struct cs_dsp *dsp, · line 2846

Quoted 12 lines

If cs_dsp_power_up() fails on or after cs_dsp_load() mark the controls disabled and free the alg regions.

drivers/firmware/cirrus/cs_dsp.c +5 -0
@@ -2838,6 +2839,11 @@ int cs_dsp_power_up(struct cs_dsp *dsp,
 
 	return 0;
 err_ena:
+	list_for_each_entry(ctl, &dsp->ctl_list, list)
+		ctl->enabled = 0;
+
+	cs_dsp_free_alg_regions(dsp);
+

Do we need something similar in cs_dsp_adsp1_power_up() as well?

Signature · 1 line
Mark Brown <[email protected]>
#2 lore raw
In reply to Richard Fitzgerald
Quoted 1 line · Richard Fitzgerald

firmware: cs_dsp: Fix memory leak on cs_dsp_power_up() error path

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.4

Thanks!

[1/1] firmware: cs_dsp: Fix memory leak on cs_dsp_power_up() error path

      https://git.kernel.org/broonie/sound/c/39d31f76ad1b

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark