public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Renninger <trenn@suse.de>
To: lenb@kernel.org
Cc: Thomas Renninger <trenn@suse.de>,
	Carlos Corbacho <carlos@strangeworlds.co.uk>,
	Matthew Garrett <mjg59@srcf.ucam.org>,
	linux-acpi@vger.kernel.org
Subject: [PATCH 2/2] x86 platform drivers, hp-wmi: Fix two memleaks
Date: Fri, 18 Dec 2009 15:29:23 +0100	[thread overview]
Message-ID: <1261146563-2228-2-git-send-email-trenn@suse.de> (raw)
In-Reply-To: <1261146563-2228-1-git-send-email-trenn@suse.de>

CC: Carlos Corbacho <carlos@strangeworlds.co.uk>
CC: Matthew Garrett <mjg59@srcf.ucam.org>
CC: linux-acpi@vger.kernel.org
CC: Len Brown <lenb@kernel.org>

Signed-off-by: Thomas Renninger <trenn@suse.de>
---
 drivers/platform/x86/hp-wmi.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index 63c3e65..01a0913 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -134,10 +134,15 @@ static int hp_wmi_perform_query(int query, int write, int value)
 
 	obj = output.pointer;
 
-	if (!obj || obj->type != ACPI_TYPE_BUFFER)
+	if (!obj)
 		return -EINVAL;
+	else if (obj->type != ACPI_TYPE_BUFFER) {
+		kfree(obj);
+		return -EINVAL;
+	}
 
 	bios_return = *((struct bios_return *)obj->buffer.pointer);
+	kfree(obj);
 	if (bios_return.return_code > 0)
 		return bios_return.return_code * -1;
 	else
@@ -340,10 +345,13 @@ static void hp_wmi_notify(u32 value, void *context)
 
 	if (!obj || obj->type != ACPI_TYPE_BUFFER || obj->buffer.length != 8) {
 		printk(KERN_INFO "HP WMI: Unknown response received\n");
+		if (obj)
+			kfree(obj);
 		return;
 	}
 
 	eventcode = *((u8 *) obj->buffer.pointer);
+	kfree(obj);
 	if (eventcode == 0x4)
 		eventcode = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0,
 						0);
-- 
1.6.3


  reply	other threads:[~2009-12-18 14:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-18 14:29 [PATCH 1/2] x86 platform drivers, wmi: Remove needless dmi MODULE_ALIAS Thomas Renninger
2009-12-18 14:29 ` Thomas Renninger [this message]
2009-12-24  5:56   ` [PATCH 2/2] x86 platform drivers, hp-wmi: Fix two memleaks Len Brown
2009-12-18 16:43 ` [PATCH 1/2] x86 platform drivers, wmi: Remove needless dmi MODULE_ALIAS Carlos Corbacho
2009-12-18 17:44 ` Anisse Astier
2009-12-18 17:54   ` Matthew Garrett
2009-12-20 20:15     ` Anisse Astier
2009-12-24  5:50 ` Len Brown

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=1261146563-2228-2-git-send-email-trenn@suse.de \
    --to=trenn@suse.de \
    --cc=carlos@strangeworlds.co.uk \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=mjg59@srcf.ucam.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox