Commit 37830662 authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Matthew Garrett

WMI: simplify handling of returned WMI blocks in parse_wdg()

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: default avatarDmitry Torokhov <dtor@mail.ru>
Signed-off-by: default avatarMatthew Garrett <mjg@redhat.com>
parent 3d2c63eb
...@@ -475,7 +475,7 @@ const struct acpi_buffer *in) ...@@ -475,7 +475,7 @@ const struct acpi_buffer *in)
} }
EXPORT_SYMBOL_GPL(wmi_set_block); 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]; char guid_string[37];
...@@ -812,7 +812,7 @@ static acpi_status parse_wdg(acpi_handle handle) ...@@ -812,7 +812,7 @@ static acpi_status parse_wdg(acpi_handle handle)
{ {
struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL}; struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL};
union acpi_object *obj; union acpi_object *obj;
struct guid_block *gblock; const struct guid_block *gblock;
struct wmi_block *wblock; struct wmi_block *wblock;
char guid_string[37]; char guid_string[37];
acpi_status status; acpi_status status;
...@@ -832,14 +832,9 @@ static acpi_status parse_wdg(acpi_handle handle) ...@@ -832,14 +832,9 @@ static acpi_status parse_wdg(acpi_handle handle)
goto out_free_pointer; goto out_free_pointer;
} }
gblock = (const struct guid_block *)obj->buffer.pointer;
total = obj->buffer.length / sizeof(struct guid_block); 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++) { for (i = 0; i < total; i++) {
/* /*
Some WMI devices, like those for nVidia hooks, have a Some WMI devices, like those for nVidia hooks, have a
...@@ -860,7 +855,7 @@ static acpi_status parse_wdg(acpi_handle handle) ...@@ -860,7 +855,7 @@ static acpi_status parse_wdg(acpi_handle handle)
wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL); wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL);
if (!wblock) { if (!wblock) {
status = AE_NO_MEMORY; status = AE_NO_MEMORY;
goto out_free_gblock; goto out_free_pointer;
} }
wblock->gblock = gblock[i]; wblock->gblock = gblock[i];
...@@ -872,8 +867,6 @@ static acpi_status parse_wdg(acpi_handle handle) ...@@ -872,8 +867,6 @@ static acpi_status parse_wdg(acpi_handle handle)
list_add_tail(&wblock->list, &wmi_blocks.list); list_add_tail(&wblock->list, &wmi_blocks.list);
} }
out_free_gblock:
kfree(gblock);
out_free_pointer: out_free_pointer:
kfree(out.pointer); kfree(out.pointer);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment