Skip to content

Commit 4e58543

Browse files
author
Andreas Gruenbacher
committed
gfs2: Refcounting fix in gfs2_thaw_super
It turns out that the .freeze_super and .thaw_super operations require the filesystem to manage the superblock refcount itself. We are using the freeze_super() and thaw_super() helpers to mostly take care of that for us, but this means that the superblock may no longer be around by when thaw_super() returns, and gfs2_thaw_super() will then access freed memory. Take an extra superblock reference in gfs2_thaw_super() to fix that. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
1 parent 5a7a964 commit 4e58543

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

fs/gfs2/super.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,7 @@ static int gfs2_thaw_super(struct super_block *sb, enum freeze_holder who)
819819
return -EINVAL;
820820
}
821821

822+
atomic_inc(&sb->s_active);
822823
gfs2_freeze_unlock(&sdp->sd_freeze_gh);
823824

824825
error = gfs2_do_thaw(sdp);
@@ -828,6 +829,7 @@ static int gfs2_thaw_super(struct super_block *sb, enum freeze_holder who)
828829
clear_bit(SDF_FROZEN, &sdp->sd_flags);
829830
}
830831
mutex_unlock(&sdp->sd_freeze_mutex);
832+
deactivate_super(sb);
831833
return error;
832834
}
833835

0 commit comments

Comments
 (0)