From: Axel Lin <axel.lin@gmail.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: Corentin Chary <corentincj@iksaif.net>,
Matthew Garrett <mjg@redhat.com>, Len Brown <len.brown@intel.com>,
Alan Jenkins <alan-jenkins@tuffmail.co.uk>,
acpi4asus-user@lists.sourceforge.net,
platform-driver-x86@vger.kernel.org
Subject: [PATCH] asus-laptop: fix a memory leak in asus_laptop_get_info error path
Date: Tue, 29 Jun 2010 11:09:47 +0800 [thread overview]
Message-ID: <1277780987.5478.2.camel@mola> (raw)
The callers of write_acpi_int_ret() pass ACPI_ALLOCATE_BUFFER,
the caller must kfree the returned buffer if AE_OK is returned.
This patch adds a missing kfree(buffer.pointer) before return -ENOMEM
if kstrdup fail.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/platform/x86/asus-laptop.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index 71db2ef..3d76c6a 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -1397,8 +1397,10 @@ static int asus_laptop_get_info(struct asus_laptop *asus)
}
}
asus->name = kstrdup(string, GFP_KERNEL);
- if (!asus->name)
+ if (!asus->name) {
+ kfree(buffer.pointer);
return -ENOMEM;
+ }
if (*string)
pr_notice(" %s model detected\n", string);
--
1.5.4.3
next reply other threads:[~2010-06-29 3:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-29 3:09 Axel Lin [this message]
2010-06-29 5:30 ` [PATCH] asus-laptop: fix a memory leak in asus_laptop_get_info error path Corentin Chary
2010-06-29 5:30 ` Corentin Chary
2010-07-01 13:53 ` Matthew Garrett
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=1277780987.5478.2.camel@mola \
--to=axel.lin@gmail.com \
--cc=acpi4asus-user@lists.sourceforge.net \
--cc=alan-jenkins@tuffmail.co.uk \
--cc=corentincj@iksaif.net \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mjg@redhat.com \
--cc=platform-driver-x86@vger.kernel.org \
/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.