Skip to content

Commit

Permalink
w1: use correct lock on error in w1_seq_show()
Browse files Browse the repository at this point in the history
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: d9411e5 ('w1: Add support for DS28EA00 sequence to w1-therm')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Dan Carpenter authored and Greg Kroah-Hartman committed Jun 12, 2015
1 parent a14ef24 commit 0c6d5c8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/w1/slaves/w1_therm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0c6d5c8

Please sign in to comment.