Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp3553558imd; Mon, 29 Oct 2018 08:48:54 -0700 (PDT) X-Google-Smtp-Source: AJdET5ejHLf0eTxcTyPPsmrcEGznfR9YvSOivbZx/MK5u7WPqMth29CsyPII6GfKzu2sOifcqKKa X-Received: by 2002:a62:6b41:: with SMTP id g62-v6mr8115111pfc.106.1540828134648; Mon, 29 Oct 2018 08:48:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540828134; cv=none; d=google.com; s=arc-20160816; b=Hqy9udHemdX8+sGZbIU7qMkZRQX4SYZfWAe4eBEG+3EW52lmDLHLoyeunWROL/PeBT DqfSm4NsyuPBkGnqwU250JH6qvNyTjgQCCtWa94ax7mBDHKsCn2Ztf2oHFERB/RC5Oyg 8Q+R5FV8uRI52qOJzd/L7ko66M9wkpZl9WWB0f1m3zg2wfPp66c2/JR49MWvLt4WADld qBSoDzhHMFnywoSNwHb6EZK4RK5/qqzMIht3Op0PhgtV8y7+2lAsAhtWymHkXnzdwA18 GmPHjEXwCloKMcMoEjZlWKO2lOOWnSJ8lR2FpniuUIVuDaw9pZfxCuhNUF++mek3U1d9 mpfw== 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 :content-language:mime-version:user-agent:date:message-id:cc:to :subject:from; bh=MAujelsgdTC/KNchtlpqU3hE6Qe9T2XeNpzJL+gaSyw=; b=QIybT1wGptYyX4+xFsLOLO2KseRwqX6W8v2yAmNmuiXk1ojXyOHR3OPsZ5AYmrMjTw /N5pjt9g2gsXFvfDD/zxZqbkarIqwEMcgl1V86QfrDN+54YhMbslJxkb1M2zZ7a1fPoY lScN1IQFyI6qkJLrpdf504wV75Ct4JN/nAh6+bRUBfGHhypSUsNQCV2bXjBkYrQje89G LO+ZpcTiYYvAHuXXy2ZtCh11j56lOLdnGzpphyLpl9CY9n0qKxvQV8qsHe8DfK0zb158 yMcQL5KXl9GvubNyR0Au2vcgotLCH88hLkBf/6P7Ox9EGJbFc/yu64QDgW1sJ1ZGj6rt y2jg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a4-v6si5982022pfo.97.2018.10.29.08.48.39; Mon, 29 Oct 2018 08:48:54 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727760AbeJ3AhD (ORCPT + 99 others); Mon, 29 Oct 2018 20:37:03 -0400 Received: from relay.sw.ru ([185.231.240.75]:46106 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727744AbeJ3AhD (ORCPT ); Mon, 29 Oct 2018 20:37:03 -0400 Received: from [172.16.24.21] by relay.sw.ru with esmtp (Exim 4.90_1) (envelope-from ) id 1gH9Pd-0006bb-8a; Mon, 29 Oct 2018 18:25:05 +0300 From: Vasily Averin Subject: [PATCH 1/7] ext4 resise: extra brelse in setup_new_flex_group_blocks() To: linux-ext4@vger.kernel.org, Theodore Ts'o Cc: Andreas Dilger , linux-kernel@vger.kernel.org, Yongqiang Yang , Yongqiang Yang Message-ID: <5d2aaeac-2a28-365d-808f-eae2e42218c9@virtuozzo.com> Date: Mon, 29 Oct 2018 18:25:04 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 ...") #? cc: stable@vger.kernel.org # 3.3+ Signed-off-by: Vasily Averin --- fs/ext4/resize.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index ebbc663d0798..c3fa30878ca8 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c @@ -605,7 +605,6 @@ static int setup_new_flex_group_blocks(struct super_block *sb, bh = bclean(handle, sb, block); if (IS_ERR(bh)) { err = PTR_ERR(bh); - bh = NULL; goto out; } overhead = ext4_group_overhead_blocks(sb, group); @@ -618,9 +617,9 @@ static int setup_new_flex_group_blocks(struct super_block *sb, ext4_mark_bitmap_end(EXT4_B2C(sbi, 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) @@ -635,18 +634,16 @@ static int setup_new_flex_group_blocks(struct super_block *sb, 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++) { @@ -685,7 +682,6 @@ static int setup_new_flex_group_blocks(struct super_block *sb, } out: - brelse(bh); err2 = ext4_journal_stop(handle); if (err2 && !err) err = err2; -- 2.17.1