linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: skeggsb@gmail.com
To: linux-acpi@vger.kernel.org
Cc: Ulrich Obergfell <uobergfe@redhat.com>, Ben Skeggs <bskeggs@redhat.com>
Subject: [PATCH] acpi: fix a leak of acpi_buffer objects in acpi_video_get_edid()
Date: Fri,  8 Apr 2011 15:12:13 +1000	[thread overview]
Message-ID: <1302239533-26893-1-git-send-email-skeggsb@gmail.com> (raw)

From: Ulrich Obergfell <uobergfe@redhat.com>

Commit 24b102d3488c9d201915d070a519e07098e0cd30 modified nouveau to take
a copy of the data returned by acpi_video_get_edid() to prevent an invalid
free later on.  This left a leak of the acpi_buffer.

A correct fix involves modifying the ACPI code to return a copy of the EDID
data, and freeing the acpi_buffer.

Signed-off-by: Ulrich Obergfell <uobergfe@redhat.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
---
 drivers/acpi/video.c                   |    8 ++++++--
 drivers/gpu/drm/nouveau/nouveau_acpi.c |    2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 31e9e10..e63ab12 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -1332,8 +1332,12 @@ int acpi_video_get_edid(struct acpi_device *device, int type, int device_id,
 			}
 		}
 
-		*edid = buffer->buffer.pointer;
-		return length;
+		*edid = kmemdup(buffer->buffer.pointer, buffer->buffer.length, GFP_KERNEL);
+		kfree(buffer);
+		if (*edid)
+			return length;
+		else
+			return -ENOMEM;
 	}
 
 	return -ENODEV;
diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c b/drivers/gpu/drm/nouveau/nouveau_acpi.c
index a542380..2d51a38 100644
--- a/drivers/gpu/drm/nouveau/nouveau_acpi.c
+++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c
@@ -297,6 +297,6 @@ nouveau_acpi_edid(struct drm_device *dev, struct drm_connector *connector)
 	if (ret < 0)
 		return ret;
 
-	nv_connector->edid = kmemdup(edid, EDID_LENGTH, GFP_KERNEL);
+	nv_connector->edid = edid;
 	return 0;
 }
-- 
1.7.4.2


                 reply	other threads:[~2011-04-08  5:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1302239533-26893-1-git-send-email-skeggsb@gmail.com \
    --to=skeggsb@gmail.com \
    --cc=bskeggs@redhat.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=uobergfe@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).