diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2016-12-14 20:10:02 -0500 |
---|---|---|
committer | Darren Hart <dvhart@linux.intel.com> | 2016-12-18 17:56:43 -0500 |
commit | 83da6b59919a71a1a97ce9863aa0267eaf6d496c (patch) | |
tree | 945790779b9a88332ed8b1000e632da01f5b4e7f | |
parent | 957ae5098185e763b5c06be6c3b4b6e98c048712 (diff) |
platform/x86: surface3-wmi: Balance locking on error path
There is a possibility that lock will be left acquired.
Consolidate error path under out_free_unlock label.
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-rw-r--r-- | drivers/platform/x86/surface3-wmi.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/platform/x86/surface3-wmi.c b/drivers/platform/x86/surface3-wmi.c index 5553b2b85e0a..cbf4d83a7271 100644 --- a/drivers/platform/x86/surface3-wmi.c +++ b/drivers/platform/x86/surface3-wmi.c | |||
@@ -60,10 +60,10 @@ static DEFINE_MUTEX(s3_wmi_lock); | |||
60 | 60 | ||
61 | static int s3_wmi_query_block(const char *guid, int instance, int *ret) | 61 | static int s3_wmi_query_block(const char *guid, int instance, int *ret) |
62 | { | 62 | { |
63 | struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
63 | acpi_status status; | 64 | acpi_status status; |
64 | union acpi_object *obj; | 65 | union acpi_object *obj; |
65 | 66 | int error = 0; | |
66 | struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
67 | 67 | ||
68 | mutex_lock(&s3_wmi_lock); | 68 | mutex_lock(&s3_wmi_lock); |
69 | status = wmi_query_block(guid, instance, &output); | 69 | status = wmi_query_block(guid, instance, &output); |
@@ -77,13 +77,14 @@ static int s3_wmi_query_block(const char *guid, int instance, int *ret) | |||
77 | obj->type == ACPI_TYPE_BUFFER ? | 77 | obj->type == ACPI_TYPE_BUFFER ? |
78 | obj->buffer.length : 0); | 78 | obj->buffer.length : 0); |
79 | } | 79 | } |
80 | kfree(obj); | 80 | error = -EINVAL; |
81 | return -EINVAL; | 81 | goto out_free_unlock; |
82 | } | 82 | } |
83 | *ret = obj->integer.value; | 83 | *ret = obj->integer.value; |
84 | out_free_unlock: | ||
84 | kfree(obj); | 85 | kfree(obj); |
85 | mutex_unlock(&s3_wmi_lock); | 86 | mutex_unlock(&s3_wmi_lock); |
86 | return 0; | 87 | return error; |
87 | } | 88 | } |
88 | 89 | ||
89 | static inline int s3_wmi_query_lid(int *ret) | 90 | static inline int s3_wmi_query_lid(int *ret) |