diff options
author | Wu Fengguang <fengguang.wu@intel.com> | 2011-11-22 16:58:35 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-11-26 09:08:36 -0800 |
commit | 46e18b7f722c2e4e9c4764774a2932debf35ece2 (patch) | |
tree | ffb7d171eb72942c181c5d7e69c3b8074a993696 /sound/pci/hda/patch_hdmi.c | |
parent | 0d2c754e96311f4968e13d1f1744b7c2e2ad3442 (diff) | |
download | lwn-46e18b7f722c2e4e9c4764774a2932debf35ece2.tar.gz lwn-46e18b7f722c2e4e9c4764774a2932debf35ece2.zip |
ALSA: hda - fix ELD memory leak
Backported from commit b95d68b8179764e29558b75cec35ef4a6a98925b.
memset(eld) clears eld->proc_entry which will leak the struct
snd_info_entry when unloading module.
Fix it by
- memset only the fields before eld->eld_buffer
- set eld->eld_valid to true _after_ all eld fields have been filled
Cc: Pierre-louis Bossart <pierre-louis.bossart@intel.com>
Acked-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'sound/pci/hda/patch_hdmi.c')
-rw-r--r-- | sound/pci/hda/patch_hdmi.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 19cb72db9c38..e287015cbbb3 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -920,20 +920,23 @@ static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid, * the unsolicited response to avoid custom WARs. */ int present = snd_hda_pin_sense(codec, pin_nid); + bool eld_valid = false; - memset(eld, 0, sizeof(*eld)); +#ifdef CONFIG_PROC_FS + memset(eld, 0, offsetof(struct hdmi_eld, proc_entry)); +#else + memset(eld, 0, sizeof(struct hdmi_eld)); +#endif eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE); if (eld->monitor_present) - eld->eld_valid = !!(present & AC_PINSENSE_ELDV); - else - eld->eld_valid = 0; + eld_valid = !!(present & AC_PINSENSE_ELDV); printk(KERN_INFO "HDMI status: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n", - codec->addr, pin_nid, eld->monitor_present, eld->eld_valid); + codec->addr, pin_nid, eld->monitor_present, eld_valid); - if (eld->eld_valid) + if (eld_valid) if (!snd_hdmi_get_eld(eld, codec, pin_nid)) snd_hdmi_show_eld(eld); |