Skip to content

Commit d344873

Browse files
rfvirgiltiwai
authored andcommitted
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 <[email protected]> Fixes: 73cfbfa ("ALSA: hda/cs35l56: Add driver for Cirrus Logic CS35L56 amplifier") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent ec6f32b commit d344873

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

sound/pci/hda/cs35l56_hda.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -732,8 +732,6 @@ static void cs35l56_hda_unbind(struct device *dev, struct device *master, void *
732732
if (cs35l56->base.fw_patched)
733733
cs_dsp_power_down(&cs35l56->cs_dsp);
734734

735-
cs_dsp_remove(&cs35l56->cs_dsp);
736-
737735
if (comps[cs35l56->index].dev == dev)
738736
memset(&comps[cs35l56->index], 0, sizeof(*comps));
739737

@@ -1035,7 +1033,7 @@ int cs35l56_hda_common_probe(struct cs35l56_hda *cs35l56, int hid, int id)
10351033
ARRAY_SIZE(cs35l56_hda_dai_config));
10361034
ret = cs35l56_force_sync_asp1_registers_from_cache(&cs35l56->base);
10371035
if (ret)
1038-
goto err;
1036+
goto dsp_err;
10391037

10401038
/*
10411039
* By default only enable one ASP1TXn, where n=amplifier index,
@@ -1061,6 +1059,8 @@ int cs35l56_hda_common_probe(struct cs35l56_hda *cs35l56, int hid, int id)
10611059

10621060
pm_err:
10631061
pm_runtime_disable(cs35l56->base.dev);
1062+
dsp_err:
1063+
cs_dsp_remove(&cs35l56->cs_dsp);
10641064
err:
10651065
gpiod_set_value_cansleep(cs35l56->base.reset_gpio, 0);
10661066

@@ -1078,6 +1078,8 @@ void cs35l56_hda_remove(struct device *dev)
10781078

10791079
component_del(cs35l56->base.dev, &cs35l56_hda_comp_ops);
10801080

1081+
cs_dsp_remove(&cs35l56->cs_dsp);
1082+
10811083
kfree(cs35l56->system_name);
10821084
pm_runtime_put_noidle(cs35l56->base.dev);
10831085

0 commit comments

Comments
 (0)