Skip to content

Commit

Permalink
platform/x86: surface3-wmi: Balance locking on error path
Browse files Browse the repository at this point in the history
There is a possibility that lock will be left acquired.
Consolidate error path under out_free_unlock label.

Reported-by: kbuild test robot <[email protected]>
Reviewed-by: Benjamin Tissoires <[email protected]>
Signed-off-by: Andy Shevchenko <[email protected]>
  • Loading branch information
andy-shev authored and dvhart committed Dec 18, 2016
1 parent 957ae50 commit 83da6b5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions drivers/platform/x86/surface3-wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ static DEFINE_MUTEX(s3_wmi_lock);

static int s3_wmi_query_block(const char *guid, int instance, int *ret)
{
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
acpi_status status;
union acpi_object *obj;

struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
int error = 0;

mutex_lock(&s3_wmi_lock);
status = wmi_query_block(guid, instance, &output);
Expand All @@ -77,13 +77,14 @@ static int s3_wmi_query_block(const char *guid, int instance, int *ret)
obj->type == ACPI_TYPE_BUFFER ?
obj->buffer.length : 0);
}
kfree(obj);
return -EINVAL;
error = -EINVAL;
goto out_free_unlock;
}
*ret = obj->integer.value;
out_free_unlock:
kfree(obj);
mutex_unlock(&s3_wmi_lock);
return 0;
return error;
}

static inline int s3_wmi_query_lid(int *ret)
Expand Down

0 comments on commit 83da6b5

Please sign in to comment.