All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wu Fengguang <fengguang.wu@intel.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org, "Wang,
	Zhenyu Z" <zhenyu.z.wang@intel.com>,
	"intel-gfx@lists.freedesktop.org"
	<intel-gfx@lists.freedesktop.org>,
	"Barnes, Jesse" <jesse.barnes@intel.com>,
	Jeremy Bush <contractfrombelow@gmail.com>,
	Christopher White <c.white@pulseforce.com>,
	"Bossart, Pierre-louis" <pierre-louis.bossart@intel.com>
Subject: [PATCH 1/2] hda - fix ELD memory leak
Date: Tue, 15 Nov 2011 22:31:55 +0800	[thread overview]
Message-ID: <20111115143155.GA28175@localhost> (raw)

memset(eld) clears eld->proc_entry which will leak the struct
snd_info_entry when unloading the module.

Fix it by
- remove memset(eld)
- set eld->eld_valid to true _after_ all eld fields have been filled
- don't access the other eld fields when (eld->eld_valid == false)

Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
 sound/pci/hda/hda_eld.c    |    5 +----
 sound/pci/hda/patch_hdmi.c |   11 +++++------
 2 files changed, 6 insertions(+), 10 deletions(-)

--- linux.orig/sound/pci/hda/hda_eld.c	2011-11-15 21:02:25.000000000 +0800
+++ linux/sound/pci/hda/hda_eld.c	2011-11-15 21:13:46.000000000 +0800
@@ -297,10 +297,10 @@ static int hdmi_update_eld(struct hdmi_e
 					buf + ELD_FIXED_BYTES + mnl + 3 * i);
 	}
 
+	e->eld_valid = true;
 	return 0;
 
 out_fail:
-	e->eld_ver = 0;
 	return -EINVAL;
 }
 
@@ -323,9 +323,6 @@ int snd_hdmi_get_eld(struct hdmi_eld *el
 	 * ELD is valid, actual eld_size is assigned in hdmi_update_eld()
 	 */
 
-	if (!eld->eld_valid)
-		return -ENOENT;
-
 	size = snd_hdmi_get_eld_size(codec, nid);
 	if (size == 0) {
 		/* wfg: workaround for ASUS P5E-VM HDMI board */
--- linux.orig/sound/pci/hda/patch_hdmi.c	2011-11-15 21:02:25.000000000 +0800
+++ linux/sound/pci/hda/patch_hdmi.c	2011-11-15 21:13:42.000000000 +0800
@@ -980,20 +980,19 @@ static void hdmi_present_sense(struct hd
 	 * 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));
+	eld->eld_valid = false;
 
 	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);

             reply	other threads:[~2011-11-15 14:31 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-15 14:31 Wu Fengguang [this message]
2011-11-15 14:33 ` [PATCH 2/2] hda - delayed ELD repoll Wu Fengguang
2011-11-15 16:56   ` Wu Fengguang
2011-11-15 16:57     ` [PATCH 2/2 v2] " Wu Fengguang
2011-11-15 17:10       ` Takashi Iwai
2011-11-16  2:35         ` Wu Fengguang
2011-11-16  7:02       ` Paul Menzel
2011-11-15 18:25   ` [PATCH 2/2] " Stephen Warren
2011-11-16  2:48     ` [alsa-devel] " Wu Fengguang
2011-11-16 15:51       ` Stephen Warren
2011-11-16 15:57         ` Takashi Iwai
2011-11-16 16:12           ` Stephen Warren
2011-11-16 16:16             ` [alsa-devel] " Takashi Iwai
2011-11-16 22:46         ` Wu Fengguang
2011-11-16 23:12           ` Wu Fengguang
2011-11-15 14:35 ` [PATCH 1/2] hda - fix ELD memory leak Takashi Iwai
2011-11-15 14:41   ` Wu Fengguang
2011-11-15 14:45     ` Takashi Iwai
2011-11-15 16:56       ` Wu Fengguang
2011-11-15 18:19 ` Stephen Warren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111115143155.GA28175@localhost \
    --to=fengguang.wu@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=c.white@pulseforce.com \
    --cc=contractfrombelow@gmail.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jesse.barnes@intel.com \
    --cc=pierre-louis.bossart@intel.com \
    --cc=tiwai@suse.de \
    --cc=zhenyu.z.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.