[PATCH 2/3] hp-wmi: Fix memleaks by freeing acpi buffers delcared as ACPI_ALLOCATE_BUFFER

Thomas Renninger
2009-10-26T16:44:26Z

C: 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>
CC: Linux-acpi@vger.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 c284217..8cea7ff 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -128,10 +128,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(output.pointer);
+ return -EINVAL;
+ }

bios_return = *((struct bios_return *)obj->buffer.pointer);
+ kfree(output.pointer);
if (bios_return.return_code > 0)
return bios_return.return_code * -1;
else
@@ -377,6 +382,9 @@ static void hp_wmi_notify(u32 value, void *context)
eventcode);
} else
printk(KERN_INFO "HP WMI: Unknown response received\n");
+
+ if(obj)
+ kfree(obj.pointer);
}

static int __init hp_wmi_input_setup(void)
--
1.6.3