From: Axel Lin <axel.lin@gmail.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: Carlos Corbacho <carlos@strangeworlds.co.uk>,
Matthew Garrett <mjg@redhat.com>, Len Brown <len.brown@intel.com>,
Thomas Renninger <trenn@suse.de>,
Andrew Morton <akpm@linux-foundation.org>,
platform-driver-x86@vger.kernel.org
Subject: [PATCH] wmi: fix memory leak in parse_wdg
Date: Thu, 03 Jun 2010 11:45:45 +0800 [thread overview]
Message-ID: <1275536745.9797.2.camel@mola> (raw)
This patch properly kfree out.pointer and gblock in error path.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/platform/x86/wmi.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index e4eaa14..bb8a3c6 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -827,8 +827,10 @@ static __init acpi_status parse_wdg(acpi_handle handle)
total = obj->buffer.length / sizeof(struct guid_block);
gblock = kmemdup(obj->buffer.pointer, obj->buffer.length, GFP_KERNEL);
- if (!gblock)
- return AE_NO_MEMORY;
+ if (!gblock) {
+ status = AE_NO_MEMORY;
+ goto out_free_pointer;
+ }
for (i = 0; i < total; i++) {
/*
@@ -848,8 +850,10 @@ static __init acpi_status parse_wdg(acpi_handle handle)
wmi_dump_wdg(&gblock[i]);
wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL);
- if (!wblock)
- return AE_NO_MEMORY;
+ if (!wblock) {
+ status = AE_NO_MEMORY;
+ goto out_free_gblock;
+ }
wblock->gblock = gblock[i];
wblock->handle = handle;
@@ -860,8 +864,10 @@ static __init acpi_status parse_wdg(acpi_handle handle)
list_add_tail(&wblock->list, &wmi_blocks.list);
}
- kfree(out.pointer);
+out_free_gblock:
kfree(gblock);
+out_free_pointer:
+ kfree(out.pointer);
return status;
}
--
1.5.4.3
reply other threads:[~2010-06-03 3:45 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=1275536745.9797.2.camel@mola \
--to=axel.lin@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=carlos@strangeworlds.co.uk \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mjg@redhat.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=trenn@suse.de \
/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