Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2996583imu; Mon, 19 Nov 2018 09:08:28 -0800 (PST) X-Google-Smtp-Source: AFSGD/VeE3ksnNy7W+KvIN4g5ltK2Qm59FlZEOl5beEs12dBYpqrwEhlLSyw/di+AGfJv+RFsnjD X-Received: by 2002:a62:a117:: with SMTP id b23-v6mr5917683pff.163.1542647308157; Mon, 19 Nov 2018 09:08:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542647308; cv=none; d=google.com; s=arc-20160816; b=aP7OZn8vahyfcXdpeVbXF8LOulGhzTRwVlDFWEIlLpaF+espvNGbT2zOxJpgvnoWcT FGgTmuNAjqEheGtfHO6PNHz6e6+AXDK1t6o88PNdcQ1Fk4zVcWnNxQ6A4WDcTvxMZpFN TIl3EJEHFWClz91UsqLN5x+w4s7BsddGtG4RXHk7Ji2h52YhejcdnHqMucmB3Y5B+vuJ d5kVvO3SOWIMqvbHEHjrB/icnUNPHEtQAsCwLllyjJgyxQHL6h6tfTklM+/VSfxOA9V9 0cWzwwkM+K1AJV1D2476CMOcCVCjbJGXVvP2ymrm8xM574j3A1cSdry5AJKB3iV45U3V Fv8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XAz4eWHnaLOdDXRtC529Ap8oYkx1fL6Hm+UdlMMi80w=; b=eYMURjZJcynVrmIa+kIVmzlxb+SsadoU6moQh41G1uDRs3NWj4aGiL95tBzaHMqEhI shI+vkHHYuCN7WCJ6P8yTQfYjLfEV9Rmkmh9rVEzXjZzgBb1lHcT/aiVV8gFCcVLMPgg VFkDJq+THoagdjM55+78vmgYt2k+LttiPVwhNjM4wLxSGKv9ZLfnBK0PxMWC1k6XDs5g kva/w6Bc3gqvWtBwm+5+5JmKcJIH7NVGTVH+53RHY9Zip6hvps3mI8HsepjbfU68Pgzb c68dUxdx9TX8IdaI2znQUfUJQZj4q+toZDlDqUR5q3g0IR7CVkOUen6pTfG0ecmu2sY1 9stw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="T9b/nY8a"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u11si24103397plz.280.2018.11.19.09.08.11; Mon, 19 Nov 2018 09:08:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="T9b/nY8a"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436524AbeKTDbU (ORCPT + 99 others); Mon, 19 Nov 2018 22:31:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:46760 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406131AbeKTDbU (ORCPT ); Mon, 19 Nov 2018 22:31:20 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 37D53214D9; Mon, 19 Nov 2018 17:07:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542647221; bh=QyCL6ml+dl7VAwzWWka/qgznhr2CJodqSBAW9cnjJl4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T9b/nY8aZK2B9BmMvzIhV330okg3e6Qo8ZM9GFNt8YAk6CY4+xRf/XNkUPuE3yzbO HT5O+WFgx1vwR4NSN3bf01wW+yKYeqhHsjgN3r7cj4s1OUdb1E11+AZAHWS9Ak38G1 cAHsxYgpSOq52T43MP5seB/Vs9vaQECZ74nFXeUQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vasily Averin , Theodore Tso , stable@kernel.org Subject: [PATCH 3.18 75/90] ext4: avoid potential extra brelse in setup_new_flex_group_blocks() Date: Mon, 19 Nov 2018 17:29:57 +0100 Message-Id: <20181119162632.244870715@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162620.585061184@linuxfoundation.org> References: <20181119162620.585061184@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vasily Averin commit 9e4028935cca3f9ef9b6a90df9da6f1f94853536 upstream. Currently bh is set to NULL only during first iteration of for cycle, then this pointer is not cleared after end of using. Therefore rollback after errors can lead to extra brelse(bh) call, decrements bh counter and later trigger an unexpected warning in __brelse() Patch moves brelse() calls in body of cycle to exclude requirement of brelse() call in rollback. Fixes: 33afdcc5402d ("ext4: add a function which sets up group blocks ...") Signed-off-by: Vasily Averin Signed-off-by: Theodore Ts'o Cc: stable@kernel.org # 3.3+ Signed-off-by: Greg Kroah-Hartman --- fs/ext4/resize.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c @@ -577,7 +577,6 @@ handle_bb: bh = bclean(handle, sb, block); if (IS_ERR(bh)) { err = PTR_ERR(bh); - bh = NULL; goto out; } overhead = ext4_group_overhead_blocks(sb, group); @@ -589,9 +588,9 @@ handle_bb: ext4_mark_bitmap_end(group_data[i].blocks_count, sb->s_blocksize * 8, bh->b_data); err = ext4_handle_dirty_metadata(handle, NULL, bh); + brelse(bh); if (err) goto out; - brelse(bh); handle_ib: if (bg_flags[i] & EXT4_BG_INODE_UNINIT) @@ -606,18 +605,16 @@ handle_ib: bh = bclean(handle, sb, block); if (IS_ERR(bh)) { err = PTR_ERR(bh); - bh = NULL; goto out; } ext4_mark_bitmap_end(EXT4_INODES_PER_GROUP(sb), sb->s_blocksize * 8, bh->b_data); err = ext4_handle_dirty_metadata(handle, NULL, bh); + brelse(bh); if (err) goto out; - brelse(bh); } - bh = NULL; /* Mark group tables in block bitmap */ for (j = 0; j < GROUP_TABLE_COUNT; j++) { @@ -648,7 +645,6 @@ handle_ib: } out: - brelse(bh); err2 = ext4_journal_stop(handle); if (err2 && !err) err = err2;