gfs2: Don't leave s_fs_info pointing to freed memory in init_sbd
authorAndrew Price <anprice@redhat.com>
Mon, 8 Oct 2018 12:52:43 +0000 (07:52 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 1 Dec 2018 08:47:59 +0000 (09:47 +0100)
commite458d80f65425d9066b6579c7a363708e2138833
tree05bf556cff7262a0fe349131432cece004ab2495
parent26e51e5287eed4d96ea66a3da95429f42940f013
gfs2: Don't leave s_fs_info pointing to freed memory in init_sbd

commit 4c62bd9cea7bcf10292f7e4c57a2bca332942697 upstream.

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: Andrew Price <anprice@redhat.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/gfs2/ops_fstype.c