btrfs: avoid null pointer dereference on fs_info when calling btrfs_crit
authorColin Ian King <colin.king@canonical.com>
Mon, 11 Sep 2017 15:15:28 +0000 (16:15 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Dec 2017 09:10:30 +0000 (10:10 +0100)
commit864a5fb1c6066ade93a640a279bcd191952e4181
tree9acf0a5bf00134396e2980df64c6469150919a78
parentda76a65a011490a0b0bd9f50d872f26e629d1eed
btrfs: avoid null pointer dereference on fs_info when calling btrfs_crit

[ Upstream commit 3993b112dac968612b0b213ed59cb30f50b0015b ]

There are checks on fs_info in __btrfs_panic to avoid dereferencing a
null fs_info, however, there is a call to btrfs_crit that may also
dereference a null fs_info. Fix this by adding a check to see if fs_info
is null and only print the s_id if fs_info is non-null.

Detected by CoverityScan CID#401973 ("Dereference after null check")

Fixes: efe120a067c8 ("Btrfs: convert printk to btrfs_ and fix BTRFS prefix")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/super.c