[PATCH 02/16] ALSA: hda/tas2781: leave hda_component in usable state

Gergo Koteles posted 16 patches 2 years ago
There is a newer version of this series
[PATCH 02/16] ALSA: hda/tas2781: leave hda_component in usable state
Posted by Gergo Koteles 2 years ago
Unloading then loading the module causes a panic.
Set only previously modified fields to null.

Signed-off-by: Gergo Koteles <soyer@irl.hu>
---
 sound/pci/hda/tas2781_hda_i2c.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/sound/pci/hda/tas2781_hda_i2c.c b/sound/pci/hda/tas2781_hda_i2c.c
index fb802802939e..077a01521eef 100644
--- a/sound/pci/hda/tas2781_hda_i2c.c
+++ b/sound/pci/hda/tas2781_hda_i2c.c
@@ -613,8 +613,11 @@ static void tas2781_hda_unbind(struct device *dev,
 	struct tasdevice_priv *tas_priv = dev_get_drvdata(dev);
 	struct hda_component *comps = master_data;
 
-	if (comps[tas_priv->index].dev == dev)
-		memset(&comps[tas_priv->index], 0, sizeof(*comps));
+	if (comps[tas_priv->index].dev == dev) {
+		comps[tas_priv->index].dev = NULL;
+		strscpy(comps->name, "", sizeof(comps->name));
+		comps[tas_priv->index].playback_hook = NULL;
+	}
 
 	tasdevice_config_info_remove(tas_priv);
 	tasdevice_dsp_remove(tas_priv);
-- 
2.43.0