Re: [PATCH] ALSA: hda/cs_dsp_ctl: Use private_free for control cleanup

From: Takashi Iwai
Date: Wed May 08 2024 - 08:33:52 EST


On Wed, 08 May 2024 11:56:27 +0200,
Richard Fitzgerald wrote:
>
> Use the control private_free callback to free the associated data
> block. This ensures that the memory won't leak, whatever way the
> control gets destroyed.
>
> The original implementation didn't actually remove the ALSA
> controls in hda_cs_dsp_control_remove(). It only freed the internal
> tracking structure. This meant it was possible to remove/unload the
> amp driver while leaving its ALSA controls still present in the
> soundcard. Obviously attempting to access them could cause segfaults
> or at least dereferencing stale pointers.
>
> Signed-off-by: Richard Fitzgerald <rf@xxxxxxxxxxxxxxxxxxxxx>
> Fixes: 3233b978af23 ("ALSA: hda: hda_cs_dsp_ctl: Add Library to support CS_DSP ALSA controls")
> ---
> This replaces my earlier "keep it simple" attempt at cleanup.
> I decided that implementing private_free is the only sensible
> way to fix the cleanup.

Applied now. Thanks.


Takashi