[PATCH 2/9] ALSA: hda: hda_cs_dsp_ctl: Only call notify when a control has been added to a card

From: Richard Fitzgerald
Date: Wed Feb 21 2024 - 10:05:34 EST


From: Simon Trimmer <simont@xxxxxxxxxxxxxxxxxxxxx>

There is a window of time where the cs_dsp_coeff_ctl has been created
but has not been registered as a control with ALSA.

The hda_cs_dsp_write_ctl() helper function can be used update the cs_dsp
coefficient before it has been registered, but it should only call
snd_ctl_notify() once the control is associated with a card.

Signed-off-by: Simon Trimmer <simont@xxxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Richard Fitzgerald <rf@xxxxxxxxxxxxxxxxxxxxx>
Fixes: e414b05e724f ("ALSA: hda: hda_cs_dsp_ctl: Add apis to write the controls directly")
---
sound/pci/hda/hda_cs_dsp_ctl.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sound/pci/hda/hda_cs_dsp_ctl.c b/sound/pci/hda/hda_cs_dsp_ctl.c
index 463ca06036bf..0f5fdd44721c 100644
--- a/sound/pci/hda/hda_cs_dsp_ctl.c
+++ b/sound/pci/hda/hda_cs_dsp_ctl.c
@@ -224,9 +224,10 @@ int hda_cs_dsp_write_ctl(struct cs_dsp *dsp, const char *name, int type,
if (ret == 0 || (cs_ctl->flags & WMFW_CTL_FLAG_SYS))
return 0;

+ /* Notify when a control has been added to a card */
ctl = cs_ctl->priv;
-
- snd_ctl_notify(ctl->card, SNDRV_CTL_EVENT_MASK_VALUE, &ctl->kctl->id);
+ if (ctl && ctl->kctl)
+ snd_ctl_notify(ctl->card, SNDRV_CTL_EVENT_MASK_VALUE, &ctl->kctl->id);

return 0;
}
--
2.30.2