Skip to content

Commit b828b4b

Browse files
dubeykoidryomov
authored andcommitted
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 <[email protected]> Reported-by: Dan Carpenter <[email protected]> Closes: https://lore.kernel.org/r/[email protected]/ Signed-off-by: Viacheslav Dubeyko <[email protected]> Reviewed by: Alex Markuze <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 72386d5 commit b828b4b

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

fs/ceph/super.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,8 +1033,7 @@ void ceph_umount_begin(struct super_block *sb)
10331033
struct ceph_fs_client *fsc = ceph_sb_to_fs_client(sb);
10341034

10351035
doutc(fsc->client, "starting forced umount\n");
1036-
if (!fsc)
1037-
return;
1036+
10381037
fsc->mount_state = CEPH_MOUNT_SHUTDOWN;
10391038
__ceph_umount_begin(fsc);
10401039
}

0 commit comments

Comments
 (0)