From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Matthew Garrett <mjg@redhat.com>
Cc: Carlos Corbacho <carlos@strangeworlds.co.uk>,
platform-driver-x86@vger.kernel.org
Subject: [PATCH 06/10] WMI: simplify handling of returned WMI blocks in parse_wdg()
Date: Thu, 26 Aug 2010 00:15:09 -0700 [thread overview]
Message-ID: <20100826071509.7976.8827.stgit@localhost.localdomain> (raw)
In-Reply-To: <20100826071442.7976.93972.stgit@localhost.localdomain>
There is no reason why we allocate memory and copy data into an
intermediate buffer, it is not like we are working with data coming
from userspace.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---
drivers/platform/x86/wmi.c | 15 ++++-----------
1 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 4032fa4..e9064fb 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -487,7 +487,7 @@ const struct acpi_buffer *in)
}
EXPORT_SYMBOL_GPL(wmi_set_block);
-static void wmi_dump_wdg(struct guid_block *g)
+static void wmi_dump_wdg(const struct guid_block *g)
{
char guid_string[37];
@@ -824,7 +824,7 @@ static acpi_status parse_wdg(acpi_handle handle)
{
struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL};
union acpi_object *obj;
- struct guid_block *gblock;
+ const struct guid_block *gblock;
struct wmi_block *wblock;
char guid_string[37];
acpi_status status;
@@ -844,14 +844,9 @@ static acpi_status parse_wdg(acpi_handle handle)
goto out_free_pointer;
}
+ gblock = (const struct guid_block *)obj->buffer.pointer;
total = obj->buffer.length / sizeof(struct guid_block);
- gblock = kmemdup(obj->buffer.pointer, obj->buffer.length, GFP_KERNEL);
- if (!gblock) {
- status = AE_NO_MEMORY;
- goto out_free_pointer;
- }
-
for (i = 0; i < total; i++) {
/*
Some WMI devices, like those for nVidia hooks, have a
@@ -872,7 +867,7 @@ static acpi_status parse_wdg(acpi_handle handle)
wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL);
if (!wblock) {
status = AE_NO_MEMORY;
- goto out_free_gblock;
+ goto out_free_pointer;
}
wblock->gblock = gblock[i];
@@ -884,8 +879,6 @@ static acpi_status parse_wdg(acpi_handle handle)
list_add_tail(&wblock->list, &wmi_blocks.list);
}
-out_free_gblock:
- kfree(gblock);
out_free_pointer:
kfree(out.pointer);
next prev parent reply other threads:[~2010-08-26 7:15 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-26 7:14 [PATCH 01/10] WMI: remove EC region handler when _WDG parsing fails Dmitry Torokhov
2010-08-26 7:14 ` [PATCH 02/10] WMI: free wmi blocks when parse_wdg() fails Dmitry Torokhov
2010-09-12 17:19 ` Carlos Corbacho
2010-08-26 7:14 ` [PATCH 03/10] WMI: fix wmi_gtoa() to actully terminate the string Dmitry Torokhov
2010-09-12 17:28 ` Carlos Corbacho
2010-08-26 7:14 ` [PATCH 04/10] WMI: do not leak memory in parse_wdg() Dmitry Torokhov
2010-09-12 17:29 ` Carlos Corbacho
2010-08-26 7:15 ` [PATCH 05/10] WMI: fix potential NULL pointer dereference Dmitry Torokhov
2010-09-12 17:30 ` Carlos Corbacho
2010-08-26 7:15 ` Dmitry Torokhov [this message]
2010-09-12 17:39 ` [PATCH 06/10] WMI: simplify handling of returned WMI blocks in parse_wdg() Carlos Corbacho
2010-08-26 7:15 ` [PATCH 07/10] WMI: use separate list head for storing wmi blocks Dmitry Torokhov
2010-09-12 17:40 ` Carlos Corbacho
2010-08-26 7:15 ` [PATCH 08/10] WMI: use pr_err() and friends Dmitry Torokhov
2010-09-12 17:42 ` Carlos Corbacho
2010-08-26 7:15 ` [PATCH 09/10] WMI: make use of class device's attributres Dmitry Torokhov
2010-09-12 17:50 ` Carlos Corbacho
2010-08-26 7:15 ` [PATCH 10/10] WMI: embed struct device directly into wmi_block Dmitry Torokhov
2010-09-12 7:29 ` [PATCH 01/10] WMI: remove EC region handler when _WDG parsing fails Dmitry Torokhov
2010-09-12 17:14 ` Carlos Corbacho
2010-10-01 17:00 ` Dmitry Torokhov
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=20100826071509.7976.8827.stgit@localhost.localdomain \
--to=dmitry.torokhov@gmail.com \
--cc=carlos@strangeworlds.co.uk \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox