ceph: fix variable dereferenced before check in ceph_umount_begin()
Subsystems (2)
Viacheslav Dubeyko
maintainerPATCH v2 1/1 ceph: fix variable dereferenced before check in ceph_umount_begin()
From: Viacheslav Dubeyko <[email protected]>
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.
--- fs/ceph/super.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ceph/super.c +1 -2
@@ -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); }
Signature · 1 line
2.49.0
Alex Markuze
maintainerReviewed by: Alex Markuze <[email protected]>
Quoted 56 lines · Viacheslav Dubeyko
From: Viacheslav Dubeyko <[email protected]>
smatch warnings:
fs/ceph/super.c:1042ceph_umount_begin()warn: variable dereferenced before check 'fsc' (see line 1041)vim +/fsc +1042
fs/ceph/super.cvoid
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]>Signed-off-by Viacheslav Dubeyko <[email protected]>--- fs/ceph/super.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/ceph/super.c +1
-3@@ -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); } --2.49.0
Ilya Dryomov
maintainerQuoted 50 lines · Alex Markuze
Reviewed by: Alex Markuze <[email protected]>
Quoted 46 lines · Viacheslav Dubeyko
From: Viacheslav Dubeyko <[email protected]>
smatch warnings:
fs/ceph/super.c:1042ceph_umount_begin()warn: variable dereferenced before check 'fsc' (see line 1041)vim +/fsc +1042
fs/ceph/super.cvoid
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]>Signed-off-by Viacheslav Dubeyko <[email protected]>--- fs/ceph/super.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/ceph/super.c +0
-0@@ -1033,8 +1033,7 @@ void ceph_umount_begin(struct super_block *sb)struct ceph_fs_client *fsc =ceph_sb_to_fs_client (sb);
Quoted 11 lines
Quoted 10 lines
fs/ceph/super.c +1
-3doutc (fsc->client,"starting forced umount\n" ); -if (!fsc) -return ; + fsc->mount_state =CEPH_MOUNT_SHUTDOWN ;__ceph_umount_begin (fsc); } --2.49.0
Applied with the Closes tag amended (Proofpoint URL).
Thanks,
Ilya