sof_ipc4_bytes_ext_put() and sof_ipc3_bytes_ext_put() keep a backup of the last known good bytes control data in scontrol->old_ipc_control_data. This backup is only released when it is restored, so it is leaked when the control is freed while the backup is still present. Free old_ipc_control_data in sof_control_unload() and sof_widget_unload(), which are the two paths that release the control data, along with the rest of the control data. Fixes: 299f6c752f8f ("ASoC: sof: Improve sof_ipc3_bytes_ext_put function") Cc: stable@vger.kernel.org Signed-off-by: Ye Weihua --- sound/soc/sof/topology.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 4dcacafb9cdb..c21a0199db9c 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -1069,10 +1069,11 @@ static int sof_control_unload(struct snd_soc_component *scomp, dev_err(scomp->dev, "failed to free control: %s\n", scontrol->name); } /* free all data before returning in case of error too */ kfree(scontrol->ipc_control_data); + kfree(scontrol->old_ipc_control_data); kfree(scontrol->priv); kfree(scontrol->name); list_del(&scontrol->list); kfree(scontrol); @@ -1717,10 +1718,11 @@ static int sof_widget_unload(struct snd_soc_component *scomp, default: dev_warn(scomp->dev, "unsupported kcontrol_type\n"); goto out; } kfree(scontrol->ipc_control_data); + kfree(scontrol->old_ipc_control_data); list_del(&scontrol->list); kfree(scontrol->name); kfree(scontrol); } -- 2.34.1