* [patch 2/2] w1: unlock correct lock on error in w1_seq_show()
@ 2015-06-01 9:56 Dan Carpenter
2015-06-02 12:12 ` David Fries
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2015-06-01 9:56 UTC (permalink / raw)
To: Evgeniy Polyakov, Matt Campbell
Cc: Greg Kroah-Hartman, David Fries, linux-kernel, kernel-janitors
Smatch complains that we don't unlock "master->mutex" on this error
path. It looks like it is a typo and we unlock ->bus_mutext where
->mutex was intended.
Fixes: d9411e57dc7f ('w1: Add support for DS28EA00 sequence to w1-therm')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
index 3351be6..79ecaf8 100644
--- a/drivers/w1/slaves/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -412,7 +412,7 @@ static ssize_t w1_seq_show(struct device *device,
c -= snprintf(buf + PAGE_SIZE - c, c, "%d\n", seq);
return PAGE_SIZE - c;
error:
- mutex_unlock(&sl->master->bus_mutex);
+ mutex_unlock(&sl->master->mutex);
return -EIO;
}
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [patch 2/2] w1: unlock correct lock on error in w1_seq_show()
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
2015-06-04 9:04 ` [patch] [patch 2/2 v2] w1: use " Dan Carpenter
0 siblings, 1 reply; 5+ messages in thread
From: David Fries @ 2015-06-02 12:12 UTC (permalink / raw)
To: Dan Carpenter
Cc: Evgeniy Polyakov, Matt Campbell, Greg Kroah-Hartman, linux-kernel,
kernel-janitors
Thanks for including me, I'm going to have to nack this though, it is
an error, but bus_mutex is correct, mutex is incorrect, so the other
two lock/unlock in that routine are the ones that need to be changed.
w1.h
* @mutex: protect most of w1_master
* @bus_mutex: pretect concurrent bus access
On Mon, Jun 01, 2015 at 12:56:32PM +0300, Dan Carpenter wrote:
> Smatch complains that we don't unlock "master->mutex" on this error
> path. It looks like it is a typo and we unlock ->bus_mutext where
> ->mutex was intended.
>
> Fixes: d9411e57dc7f ('w1: Add support for DS28EA00 sequence to w1-therm')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
> index 3351be6..79ecaf8 100644
> --- a/drivers/w1/slaves/w1_therm.c
> +++ b/drivers/w1/slaves/w1_therm.c
> @@ -412,7 +412,7 @@ static ssize_t w1_seq_show(struct device *device,
> c -= snprintf(buf + PAGE_SIZE - c, c, "%d\n", seq);
> return PAGE_SIZE - c;
> error:
> - mutex_unlock(&sl->master->bus_mutex);
> + mutex_unlock(&sl->master->mutex);
> return -EIO;
> }
>
--
David Fries <david@fries.net>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [patch] [patch 2/2 v2] w1: use correct lock on error in w1_seq_show()
2015-06-02 12:12 ` David Fries
@ 2015-06-04 9:04 ` Dan Carpenter
2015-06-11 15:31 ` Evgeniy Polyakov
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2015-06-04 9:04 UTC (permalink / raw)
To: Evgeniy Polyakov
Cc: Greg Kroah-Hartman, David Fries, Matt Campbell, linux-kernel,
kernel-janitors
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;
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [patch] [patch 2/2 v2] w1: use correct lock on error in w1_seq_show()
2015-06-04 9:04 ` [patch] [patch 2/2 v2] w1: use " Dan Carpenter
@ 2015-06-11 15:31 ` Evgeniy Polyakov
2015-06-11 23:41 ` David Fries
0 siblings, 1 reply; 5+ messages in thread
From: Evgeniy Polyakov @ 2015-06-11 15:31 UTC (permalink / raw)
To: Dan Carpenter
Cc: Greg Kroah-Hartman, David Fries, Matt Campbell,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Hi
04.06.2015, 12:04, "Dan Carpenter" <dan.carpenter@oracle.com>:
> 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>
Looks good to me, Greg please pull this serie into your tree, if you hadn't yet.
Am I right that this is a stable tree material too?
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] [patch 2/2 v2] w1: use correct lock on error in w1_seq_show()
2015-06-11 15:31 ` Evgeniy Polyakov
@ 2015-06-11 23:41 ` David Fries
0 siblings, 0 replies; 5+ messages in thread
From: David Fries @ 2015-06-11 23:41 UTC (permalink / raw)
To: Evgeniy Polyakov
Cc: Dan Carpenter, Greg Kroah-Hartman, Matt Campbell,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
On Thu, Jun 11, 2015 at 06:31:00PM +0300, Evgeniy Polyakov wrote:
> Hi
>
> 04.06.2015, 12:04, "Dan Carpenter" <dan.carpenter@oracle.com>:
> > 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>
>
> Looks good to me, Greg please pull this serie into your tree, if you hadn't yet.
> Am I right that this is a stable tree material too?
I would expect the answer to be no. This is a fix to a new feature
that is in gregkh/char-misc but not yet in Linus's tree.
--
David Fries <david@fries.net>
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-06-11 23:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2015-06-04 9:04 ` [patch] [patch 2/2 v2] w1: use " Dan Carpenter
2015-06-11 15:31 ` Evgeniy Polyakov
2015-06-11 23:41 ` David Fries
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox