From: Viacheslav Dubeyko Date: Mon, 2 Jun 2025 18:49:56 +0000 (-0700) Subject: ceph: fix variable dereferenced before check in ceph_umount_begin() X-Git-Tag: v6.16-rc1~21^2 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=b828b4bf29d10a3e505a76a39c4daea969e19dc9;p=linux-block.git ceph: fix variable dereferenced before check in ceph_umount_begin() smatch warnings: fs/ceph/super.c:1042 ceph_umount_begin() warn: variable dereferenced before check 'fsc' (see line 1041) vim +/fsc +1042 fs/ceph/super.c void ceph_umount_begin(struct super_block *sb) { struct ceph_fs_client *fsc = ceph_sb_to_fs_client(sb); doutc(fsc->client, "starting forced umount\n"); ^^^^^^^^^^^ Dereferenced if (!fsc) ^^^^ Checked too late. return; fsc->mount_state = CEPH_MOUNT_SHUTDOWN; __ceph_umount_begin(fsc); } The VFS guarantees that the superblock is still alive when it calls into ceph via ->umount_begin(). Finally, we don't need to check the fsc and it should be valid. This patch simply removes the fsc check. Reported-by: kernel test robot Reported-by: Dan Carpenter Closes: https://lore.kernel.org/r/202503280852.YDB3pxUY-lkp@intel.com/ Signed-off-by: Viacheslav Dubeyko Reviewed by: Alex Markuze Signed-off-by: Ilya Dryomov --- diff --git a/fs/ceph/super.c b/fs/ceph/super.c index fc4cab8b7b77..2b8438d8a324 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c @@ -1033,8 +1033,7 @@ void ceph_umount_begin(struct super_block *sb) struct ceph_fs_client *fsc = ceph_sb_to_fs_client(sb); doutc(fsc->client, "starting forced umount\n"); - if (!fsc) - return; + fsc->mount_state = CEPH_MOUNT_SHUTDOWN; __ceph_umount_begin(fsc); }