All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: hda: increment codec device refcount when it is added to the card
@ 2019-05-30 20:18 Ranjani Sridharan
  2019-05-30 21:00 ` Pierre-Louis Bossart
  0 siblings, 1 reply; 12+ messages in thread
From: Ranjani Sridharan @ 2019-05-30 20:18 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, broonie, pierre-louis.bossart

Calling snd_device_new() makes the codec devices managed by the card.
So, when the card is removed, the refcount for the codec
device is decremented and results in the codec device's kobject
being cleaned up if the refcount is 0. But, this leads to a NULL
pointer exception while attempting to remove the symlinks when the
codec driver is released later on. Therefore, increment the codec
device's refcount before adding it to the card to prevent this.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
---
 sound/pci/hda/hda_codec.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index b20eb7fc83eb..0d5d95b07e19 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -985,6 +985,14 @@ int snd_hda_codec_device_new(struct hda_bus *bus, struct snd_card *card,
 		codec->core.subsystem_id, codec->core.revision_id);
 	snd_component_add(card, component);
 
+	/*
+	 * snd_device_new() makes the codec device managed by the card.
+	 * When the card is removed, the device reference count is
+	 * decremented. Therefore, increment it here to prevent removing
+	 * the codec device's kobject when the card is removed.
+	 */
+	get_device(hda_codec_dev(codec));
+
 	err = snd_device_new(card, SNDRV_DEV_CODEC, codec, &dev_ops);
 	if (err < 0)
 		goto error;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-05-31 15:45 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-30 20:18 [PATCH] ASoC: hda: increment codec device refcount when it is added to the card Ranjani Sridharan
2019-05-30 21:00 ` Pierre-Louis Bossart
2019-05-31  6:11   ` Takashi Iwai
2019-05-31 13:18     ` Ranjani Sridharan
2019-05-31 13:25       ` Takashi Iwai
2019-05-31 13:52         ` Ranjani Sridharan
2019-05-31 14:02           ` Takashi Iwai
2019-05-31 14:28             ` Takashi Iwai
2019-05-31 15:20               ` Ranjani Sridharan
2019-05-31 15:37                 ` Takashi Iwai
2019-05-31 15:43                   ` Ranjani Sridharan
2019-05-31 15:45                     ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.