From: Bob Peterson Date: Mon, 8 Jan 2018 15:12:28 -0500 (EST) Subject: [Cluster-devel] [PATCH 03/12] gfs2: Clean up trunc_start error path In-Reply-To: <20171222143507.26680-4-agruenba@redhat.com> References: <20171222143507.26680-1-agruenba@redhat.com> <20171222143507.26680-4-agruenba@redhat.com> Message-ID: <1732078713.4168841.1515442348230.JavaMail.zimbra@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit ----- Original Message ----- | Signed-off-by: Andreas Gruenbacher | --- | fs/gfs2/bmap.c | 15 +++++---------- | 1 file changed, 5 insertions(+), 10 deletions(-) | | diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c | index 8b993e4d80b2..0ad6d812c78b 100644 | --- a/fs/gfs2/bmap.c | +++ b/fs/gfs2/bmap.c | @@ -1022,7 +1022,7 @@ static int trunc_start(struct inode *inode, u64 | oldsize, u64 newsize) | struct gfs2_inode *ip = GFS2_I(inode); | struct gfs2_sbd *sdp = GFS2_SB(inode); | struct address_space *mapping = inode->i_mapping; | - struct buffer_head *dibh; | + struct buffer_head *dibh = NULL; | int journaled = gfs2_is_jdata(ip); | int error; | | @@ -1045,7 +1045,7 @@ static int trunc_start(struct inode *inode, u64 | oldsize, u64 newsize) | if (newsize & (u64)(sdp->sd_sb.sb_bsize - 1)) { | error = gfs2_block_truncate_page(mapping, newsize); | if (error) | - goto out_brelse; | + goto out; | } | ip->i_diskflags |= GFS2_DIF_TRUNC_IN_PROG; | } | @@ -1059,15 +1059,10 @@ static int trunc_start(struct inode *inode, u64 | oldsize, u64 newsize) | else | truncate_pagecache(inode, newsize); | | - if (error) { | - brelse(dibh); | - return error; | - } | - | -out_brelse: | - brelse(dibh); | out: | - gfs2_trans_end(sdp); | + brelse(dibh); | + if (current->journal_info) | + gfs2_trans_end(sdp); | return error; | } Hi, This isn't quite right. error = gfs2_meta_inode_buffer(ip, &dibh); if (error) goto out; ... out: brelse(dibh); If this returns an error, we'll do double brelse in out. If gfs2_meta_inode_buffer returns an error, it has released the buffer_head already. Regards, Bob Peterson Red Hat File Systems