ALSA: hda - Release ELD proc file
authorTakashi Iwai <tiwai@suse.de>
Fri, 21 Nov 2008 08:11:50 +0000 (09:11 +0100)
committerTakashi Iwai <tiwai@suse.de>
Fri, 21 Nov 2008 08:17:30 +0000 (09:17 +0100)
Release ELD proc file when reconfigured so that no leak occurs.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_eld.c
sound/pci/hda/hda_local.h
sound/pci/hda/patch_intelhdmi.c

index d2b7ccca3bb3a1186bed4d3d7f46d5c7ebe63a75..8740e7be8b24c6d8dd5ded29d99349180ae6e00d 100644 (file)
@@ -567,8 +567,17 @@ int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld)
        snd_info_set_text_ops(entry, eld, hdmi_print_eld_info);
        entry->c.text.write = hdmi_write_eld_item;
        entry->mode |= S_IWUSR;
+       eld->proc_entry = entry;
 
        return 0;
 }
 
-#endif
+void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld)
+{
+       if (!codec->bus->shutdown && eld->proc_entry) {
+               snd_device_free(codec->bus->card, eld->proc_entry);
+               eld->proc_entry = NULL;
+       }
+}
+
+#endif /* CONFIG_PROC_FS */
index c71505a4f99d3d646bb8f2e8e517aa37dba27c0f..bf7ba8b62973f0ed05fc98727d28c7186218007a 100644 (file)
@@ -481,6 +481,9 @@ struct hdmi_eld {
        int     spk_alloc;
        int     sad_count;
        struct cea_sad sad[ELD_MAX_SAD];
+#ifdef CONFIG_PROC_FS
+       struct snd_info_entry *proc_entry;
+#endif
 };
 
 int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid);
@@ -489,12 +492,17 @@ void snd_hdmi_show_eld(struct hdmi_eld *eld);
 
 #ifdef CONFIG_PROC_FS
 int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld);
+void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld);
 #else
 static inline int snd_hda_eld_proc_new(struct hda_codec *codec,
                                       struct hdmi_eld *eld)
 {
        return 0;
 }
+static inline void snd_hda_eld_proc_free(struct hda_codec *codec,
+                                        struct hdmi_eld *eld)
+{
+}
 #endif
 
 #define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80
index 5393f84f6755853aad5a04fd561ae0cd5c2c11c4..58aaf06589a861f7f0b560242e9b9e7b86cb3e12 100644 (file)
@@ -637,7 +637,10 @@ static int intel_hdmi_init(struct hda_codec *codec)
 
 static void intel_hdmi_free(struct hda_codec *codec)
 {
-       kfree(codec->spec);
+       struct intel_hdmi_spec *spec = codec->spec;
+
+       snd_hda_eld_proc_free(codec, &spec->sink_eld);
+       kfree(spec);
 }
 
 static struct hda_codec_ops intel_hdmi_patch_ops = {