This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
The following commit(s) were added to refs/heads/master by this push:
new 626f14bf libgfs2: Add NULL-checking for ip->i_bh in inode_put()
626f14bf is described below
commit 626f14bfad3eeff2f2ae05c5ffa3da9c7ac8e4e1
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri Sep 24 12:34:25 2021 +0100
libgfs2: Add NULL-checking for ip->i_bh in inode_put()
Fixes a segfault in fsck.gfs2 when checking gfs1 filesystems and defends
against any other code that might call inode_put() on an inode without a
bh set.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/fs_ops.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index eb695a3e..449873b9 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -93,21 +93,16 @@ void inode_put(struct gfs2_inode **ip_in)
uint64_t block = ip->i_num.in_addr;
struct gfs2_sbd *sdp = ip->i_sbd;
- if (ip->i_bh->b_modified) {
- lgfs2_dinode_out(ip, ip->i_bh->b_data);
- if (!ip->bh_owned && is_system_inode(sdp, block))
- fprintf(stderr, "Warning: Change made to inode "
- "were discarded.\n");
- /* This is for debugging only: a convenient place to set
- a breakpoint. This means a system inode was modified but
- not written. That's not fatal: some places like
- adjust_inode in gfs2_convert will do this on purpose.
- It can also point out a coding problem, but we don't
- want to raise alarm in the users either. */
+ if (ip->i_bh != NULL) {
+ if (ip->i_bh->b_modified) {
+ lgfs2_dinode_out(ip, ip->i_bh->b_data);
+ if (!ip->bh_owned && is_system_inode(sdp, block))
+ fprintf(stderr, "Warning: Changes made to inode were discarded.\n");
+ }
+ if (ip->bh_owned)
+ brelse(ip->i_bh);
+ ip->i_bh = NULL;
}
- if (ip->bh_owned)
- brelse(ip->i_bh);
- ip->i_bh = NULL;
free(ip);
*ip_in = NULL; /* make sure the memory isn't accessed again */
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
Show replies by date