Commit 83da6b59 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Darren Hart

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: default avatarkbuild test robot <fengguang.wu@intel.com>
Reviewed-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
parent 957ae509
...@@ -60,10 +60,10 @@ static DEFINE_MUTEX(s3_wmi_lock); ...@@ -60,10 +60,10 @@ static DEFINE_MUTEX(s3_wmi_lock);
static int s3_wmi_query_block(const char *guid, int instance, int *ret) static int s3_wmi_query_block(const char *guid, int instance, int *ret)
{ {
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
acpi_status status; acpi_status status;
union acpi_object *obj; union acpi_object *obj;
int error = 0;
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
mutex_lock(&s3_wmi_lock); mutex_lock(&s3_wmi_lock);
status = wmi_query_block(guid, instance, &output); 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,13 +77,14 @@ static int s3_wmi_query_block(const char *guid, int instance, int *ret)
obj->type == ACPI_TYPE_BUFFER ? obj->type == ACPI_TYPE_BUFFER ?
obj->buffer.length : 0); obj->buffer.length : 0);
} }
kfree(obj); error = -EINVAL;
return -EINVAL; goto out_free_unlock;
} }
*ret = obj->integer.value; *ret = obj->integer.value;
out_free_unlock:
kfree(obj); kfree(obj);
mutex_unlock(&s3_wmi_lock); mutex_unlock(&s3_wmi_lock);
return 0; return error;
} }
static inline int s3_wmi_query_lid(int *ret) static inline int s3_wmi_query_lid(int *ret)
......
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