From: Dan Carpenter <dan.carpenter@oracle.com>
To: Evgeniy Polyakov <zbr@ioremap.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
David Fries <David@Fries.net>,
Matt Campbell <mattrcampbell@gmail.com>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] [patch 2/2 v2] w1: use correct lock on error in w1_seq_show()
Date: Thu, 4 Jun 2015 12:04:12 +0300 [thread overview]
Message-ID: <20150604090412.GE22838@mwanda> (raw)
In-Reply-To: <20150602121255.GA20149@spacedout.fries.net>
I noticed there was a problem here because Smatch complained:
drivers/w1/slaves/w1_therm.c:416 w1_seq_show() warn:
inconsistent returns 'mutex:&sl->master->mutex'.
Locked on: line 416
Unlocked on: line 413
The problem is that we lock ->mutex but we unlock ->bus_mutex on error.
David Fries says that ->bus_mutex is correct and ->mutex is incorrect.
Fixes: d9411e57dc7f ('w1: Add support for DS28EA00 sequence to w1-therm')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: In the first version I changed ->bus_mutext to ->mutex instead of
the other way around.
diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
index d21e686..06b034c 100644
--- a/drivers/w1/slaves/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -355,7 +355,7 @@ static ssize_t w1_seq_show(struct device *device,
struct w1_reg_num *reg_num;
int seq = 0;
- mutex_lock(&sl->master->mutex);
+ mutex_lock(&sl->master->bus_mutex);
/* Place all devices in CHAIN state */
if (w1_reset_bus(sl->master))
goto error;
@@ -407,7 +407,7 @@ static ssize_t w1_seq_show(struct device *device,
ack = w1_read_8(sl->master);
if (ack != W1_42_SUCCESS_CONFIRM_BYTE)
goto error;
- mutex_unlock(&sl->master->mutex);
+ mutex_unlock(&sl->master->bus_mutex);
c -= snprintf(buf + PAGE_SIZE - c, c, "%d\n", seq);
return PAGE_SIZE - c;
next prev parent reply other threads:[~2015-06-04 9:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-01 9:56 [patch 2/2] w1: unlock correct lock on error in w1_seq_show() Dan Carpenter
2015-06-02 12:12 ` David Fries
[not found] ` <CA+gYwTGSBAjSPyUSUwknOmm8SoFzHFdJmoYPVA9yN61aWO7sdA@mail.gmail.com>
2015-06-03 1:07 ` David Fries
2015-06-03 1:54 ` Matt Campbell
2015-06-03 2:39 ` David Fries
2015-06-04 9:04 ` Dan Carpenter [this message]
2015-06-11 15:31 ` [patch] [patch 2/2 v2] w1: use " Evgeniy Polyakov
2015-06-11 23:41 ` David Fries
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=20150604090412.GE22838@mwanda \
--to=dan.carpenter@oracle.com \
--cc=David@Fries.net \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mattrcampbell@gmail.com \
--cc=zbr@ioremap.net \
/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