From patchwork Fri Mar 14 23:49:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Pandit X-Patchwork-Id: 3836041 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7F45E9F43E for ; Fri, 14 Mar 2014 23:50:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 837932028D for ; Fri, 14 Mar 2014 23:50:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7E98E20304 for ; Fri, 14 Mar 2014 23:50:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756255AbaCNXtv (ORCPT ); Fri, 14 Mar 2014 19:49:51 -0400 Received: from nbl-ex10-fe02.nebula.fi ([188.117.32.122]:64356 "EHLO ex10.nebula.fi" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755659AbaCNXtt (ORCPT ); Fri, 14 Mar 2014 19:49:49 -0400 Received: from localhost.localdomain (88.195.158.30) by ex10.nebula.fi (188.117.32.115) with Microsoft SMTP Server (TLS) id 14.3.174.1; Sat, 15 Mar 2014 01:55:21 +0200 Date: Sat, 15 Mar 2014 01:49:45 +0200 From: Rakesh Pandit To: Subject: [PATCH] Btrfs-progs: scrub: don't call unlock if pthread_mutex_lock fails Message-ID: <20140314234943.GA28451@localhost.localdomain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Originating-IP: [88.195.158.30] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If pthread_mutex_lock fails (rare but fix it anyway), don't call pthread_mutex_unlock on mutex. Signed-off-by: Rakesh Pandit --- cmds-scrub.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmds-scrub.c b/cmds-scrub.c index 128537b..ca11fb5 100644 --- a/cmds-scrub.c +++ b/cmds-scrub.c @@ -776,7 +776,7 @@ static int scrub_write_progress(pthread_mutex_t *m, const char *fsid, ret = pthread_mutex_lock(m); if (ret) { err = -ret; - goto out; + goto fail; } ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old); @@ -808,6 +808,7 @@ out: if (ret && !err) err = -ret; +fail: ret = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old); if (ret && !err) err = -ret;