Commit 4c62bd9c authored by Andrew Price's avatar Andrew Price Committed by Bob Peterson

gfs2: Don't leave s_fs_info pointing to freed memory in init_sbd

When alloc_percpu() fails, sdp gets freed but sb->s_fs_info still points
to the same address. Move the assignment after that error check so that
s_fs_info can only point to a valid sdp or NULL, which is checked for
later in the error path, in gfs2_kill_super().

Reported-by: syzbot+dcb8b3587445007f5808@syzkaller.appspotmail.com
Signed-off-by: default avatarAndrew Price <anprice@redhat.com>
Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
parent e54c78a2
...@@ -72,13 +72,13 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb) ...@@ -72,13 +72,13 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
if (!sdp) if (!sdp)
return NULL; return NULL;
sb->s_fs_info = sdp;
sdp->sd_vfs = sb; sdp->sd_vfs = sb;
sdp->sd_lkstats = alloc_percpu(struct gfs2_pcpu_lkstats); sdp->sd_lkstats = alloc_percpu(struct gfs2_pcpu_lkstats);
if (!sdp->sd_lkstats) { if (!sdp->sd_lkstats) {
kfree(sdp); kfree(sdp);
return NULL; return NULL;
} }
sb->s_fs_info = sdp;
set_bit(SDF_NOJOURNALID, &sdp->sd_flags); set_bit(SDF_NOJOURNALID, &sdp->sd_flags);
gfs2_tune_init(&sdp->sd_tune); gfs2_tune_init(&sdp->sd_tune);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment