Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752839AbbFDJFD (ORCPT ); Thu, 4 Jun 2015 05:05:03 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:51209 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752629AbbFDJE4 (ORCPT ); Thu, 4 Jun 2015 05:04:56 -0400 Date: Thu, 4 Jun 2015 12:04:12 +0300 From: Dan Carpenter To: Evgeniy Polyakov Cc: Greg Kroah-Hartman , David Fries , Matt Campbell , 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() Message-ID: <20150604090412.GE22838@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150602121255.GA20149@spacedout.fries.net> User-Agent: Mutt/1.5.23 (2014-03-12) X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1601 Lines: 43 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 --- 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; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/