Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ALSA: hda: cs35l56: Fix lifetime of cs_dsp instance

The cs_dsp instance is initialized in the driver probe() so it
should be freed in the driver remove(). Also fix a missing call
to cs_dsp_remove() in the error path of cs35l56_hda_common_probe().

The call to cs_dsp_remove() was being done in the component unbind
callback cs35l56_hda_unbind(). This meant that if the driver was
unbound and then re-bound it would be using an uninitialized cs_dsp
instance.

It is best to initialize the cs_dsp instance in probe() so that it
can return an error if it fails. The component binding API doesn't
have any error handling so there's no way to handle a failure if
cs_dsp was initialized in the bind.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 73cfbfa9caea ("ALSA: hda/cs35l56: Add driver for Cirrus Logic CS35L56 amplifier")
Link: https://lore.kernel.org/r/20240508100811.49514-1-rf@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Richard Fitzgerald and committed by
Takashi Iwai
d344873c ec6f32bc

+5 -3
+5 -3
sound/pci/hda/cs35l56_hda.c
··· 732 732 if (cs35l56->base.fw_patched) 733 733 cs_dsp_power_down(&cs35l56->cs_dsp); 734 734 735 - cs_dsp_remove(&cs35l56->cs_dsp); 736 - 737 735 if (comps[cs35l56->index].dev == dev) 738 736 memset(&comps[cs35l56->index], 0, sizeof(*comps)); 739 737 ··· 1033 1035 ARRAY_SIZE(cs35l56_hda_dai_config)); 1034 1036 ret = cs35l56_force_sync_asp1_registers_from_cache(&cs35l56->base); 1035 1037 if (ret) 1036 - goto err; 1038 + goto dsp_err; 1037 1039 1038 1040 /* 1039 1041 * By default only enable one ASP1TXn, where n=amplifier index, ··· 1059 1061 1060 1062 pm_err: 1061 1063 pm_runtime_disable(cs35l56->base.dev); 1064 + dsp_err: 1065 + cs_dsp_remove(&cs35l56->cs_dsp); 1062 1066 err: 1063 1067 gpiod_set_value_cansleep(cs35l56->base.reset_gpio, 0); 1064 1068 ··· 1077 1077 pm_runtime_disable(cs35l56->base.dev); 1078 1078 1079 1079 component_del(cs35l56->base.dev, &cs35l56_hda_comp_ops); 1080 + 1081 + cs_dsp_remove(&cs35l56->cs_dsp); 1080 1082 1081 1083 kfree(cs35l56->system_name); 1082 1084 pm_runtime_put_noidle(cs35l56->base.dev);