From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: linux-kernel@vger.kernel.org
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
Darren Hart <dvhart@infradead.org>,
"open list:X86 PLATFORM DRIVERS"
<platform-driver-x86@vger.kernel.org>
Subject: [PATCH 1/1] platform/x86: surface3-wmi: Balance locking on error path
Date: Thu, 15 Dec 2016 03:24:58 +0200 [thread overview]
Message-ID: <20161215012458.501-1-andriy.shevchenko@linux.intel.com> (raw)
There is a possibility that lock will be left acquired.
Consolidate error path under out_free_unlock label.
Reported-by: kbuild test robot <lkp@intel.com>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/platform/x86/surface3-wmi.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/platform/x86/surface3-wmi.c b/drivers/platform/x86/surface3-wmi.c
index 5553b2b85e0a..ed7a3b77a0cc 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);
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);
@@ -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)
--
2.11.0
next reply other threads:[~2016-12-15 1:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-15 1:24 Andy Shevchenko [this message]
2016-12-15 6:38 ` [PATCH 1/1] platform/x86: surface3-wmi: Balance locking on error path Darren Hart
2016-12-15 8:14 ` Benjamin Tissoires
-- strict thread matches above, loose matches on Subject: below --
2016-12-15 1:26 Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161215012458.501-1-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=benjamin.tissoires@redhat.com \
--cc=dvhart@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox