diff options
| author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-08-26 03:15:09 -0400 |
|---|---|---|
| committer | Matthew Garrett <mjg@redhat.com> | 2010-10-21 09:36:47 -0400 |
| commit | 378306628e26d2945a1ed245f177a693c314e68d (patch) | |
| tree | c32dbd4988e1e51bbbff88fa8e20221492b34c06 /drivers/platform | |
| parent | 3d2c63eb5e0abfd06b19928c8ed43020b3451a3c (diff) | |
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: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
Diffstat (limited to 'drivers/platform')
| -rw-r--r-- | 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 81552bca6ae4..f6e85c8122de 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c | |||
| @@ -475,7 +475,7 @@ const struct acpi_buffer *in) | |||
| 475 | } | 475 | } |
| 476 | EXPORT_SYMBOL_GPL(wmi_set_block); | 476 | EXPORT_SYMBOL_GPL(wmi_set_block); |
| 477 | 477 | ||
| 478 | static void wmi_dump_wdg(struct guid_block *g) | 478 | static void wmi_dump_wdg(const struct guid_block *g) |
| 479 | { | 479 | { |
| 480 | char guid_string[37]; | 480 | char guid_string[37]; |
| 481 | 481 | ||
| @@ -812,7 +812,7 @@ static acpi_status parse_wdg(acpi_handle handle) | |||
| 812 | { | 812 | { |
| 813 | struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL}; | 813 | struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL}; |
| 814 | union acpi_object *obj; | 814 | union acpi_object *obj; |
| 815 | struct guid_block *gblock; | 815 | const struct guid_block *gblock; |
| 816 | struct wmi_block *wblock; | 816 | struct wmi_block *wblock; |
| 817 | char guid_string[37]; | 817 | char guid_string[37]; |
| 818 | acpi_status status; | 818 | acpi_status status; |
| @@ -832,14 +832,9 @@ static acpi_status parse_wdg(acpi_handle handle) | |||
| 832 | goto out_free_pointer; | 832 | goto out_free_pointer; |
| 833 | } | 833 | } |
| 834 | 834 | ||
| 835 | gblock = (const struct guid_block *)obj->buffer.pointer; | ||
| 835 | total = obj->buffer.length / sizeof(struct guid_block); | 836 | total = obj->buffer.length / sizeof(struct guid_block); |
| 836 | 837 | ||
| 837 | gblock = kmemdup(obj->buffer.pointer, obj->buffer.length, GFP_KERNEL); | ||
| 838 | if (!gblock) { | ||
| 839 | status = AE_NO_MEMORY; | ||
| 840 | goto out_free_pointer; | ||
| 841 | } | ||
| 842 | |||
| 843 | for (i = 0; i < total; i++) { | 838 | for (i = 0; i < total; i++) { |
| 844 | /* | 839 | /* |
| 845 | Some WMI devices, like those for nVidia hooks, have a | 840 | Some WMI devices, like those for nVidia hooks, have a |
| @@ -860,7 +855,7 @@ static acpi_status parse_wdg(acpi_handle handle) | |||
| 860 | wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL); | 855 | wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL); |
| 861 | if (!wblock) { | 856 | if (!wblock) { |
| 862 | status = AE_NO_MEMORY; | 857 | status = AE_NO_MEMORY; |
| 863 | goto out_free_gblock; | 858 | goto out_free_pointer; |
| 864 | } | 859 | } |
| 865 | 860 | ||
| 866 | wblock->gblock = gblock[i]; | 861 | wblock->gblock = gblock[i]; |
| @@ -872,8 +867,6 @@ static acpi_status parse_wdg(acpi_handle handle) | |||
| 872 | list_add_tail(&wblock->list, &wmi_blocks.list); | 867 | list_add_tail(&wblock->list, &wmi_blocks.list); |
| 873 | } | 868 | } |
| 874 | 869 | ||
| 875 | out_free_gblock: | ||
| 876 | kfree(gblock); | ||
| 877 | out_free_pointer: | 870 | out_free_pointer: |
| 878 | kfree(out.pointer); | 871 | kfree(out.pointer); |
| 879 | 872 | ||
