public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Xiaotian Feng <dfeng@redhat.com>
To: len.brown@intel.com, rui.zhang@intel.com, yakui.zhao@intel.com,
	bjorn.helgaas@hp.com, ak@linux.intel.com
Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Xiaotian Feng <dfeng@redhat.com>
Subject: [PATCH] drivers/acpi: fix memory leak in acpi_device_set_id
Date: Fri,  4 Sep 2009 15:00:19 +0800	[thread overview]
Message-ID: <1252047619-2924-1-git-send-email-dfeng@redhat.com> (raw)

In acpi_device_set_id, if cid_list is allocated by ACPI_ALLOCATE_ZEROED,
it is never freed. This patch fixes the memory leak. 

Signed-off-by: Xiaotian Feng <dfeng@redhat.com>
---
 drivers/acpi/scan.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 781435d..a0102ad 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1010,6 +1010,7 @@ static void acpi_device_set_id(struct acpi_device *device,
 	struct acpi_compatible_id_list *cid_list = NULL;
 	const char *cid_add = NULL;
 	acpi_status status;
+	int free_cid_list = 0;
 
 	switch (type) {
 	case ACPI_BUS_TYPE_DEVICE:
@@ -1098,6 +1099,7 @@ static void acpi_device_set_id(struct acpi_device *device,
 				kfree(buffer.pointer);
 				return;
 			} else {
+				free_cid_list = 1;
 				cid_list->count = 0;
 				cid_list->size = size;
 			}
@@ -1124,6 +1126,8 @@ static void acpi_device_set_id(struct acpi_device *device,
 			printk(KERN_ERR PREFIX "Memory allocation error\n");
 	}
 
+	if (free_cid_list)
+		ACPI_FREE(cid_list);
 	kfree(buffer.pointer);
 }
 
-- 
1.6.2.5

             reply	other threads:[~2009-09-04  7:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-04  7:00 Xiaotian Feng [this message]
2009-09-04 15:23 ` [PATCH] drivers/acpi: fix memory leak in acpi_device_set_id Bjorn Helgaas

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=1252047619-2924-1-git-send-email-dfeng@redhat.com \
    --to=dfeng@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=bjorn.helgaas@hp.com \
    --cc=len.brown@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=yakui.zhao@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox