OSDN Git Service

smb: client: fix warning in cifs_match_super()
authorPaulo Alcantara <pc@manguebit.com>
Mon, 19 Jun 2023 19:52:01 +0000 (16:52 -0300)
committerSteve French <stfrench@microsoft.com>
Mon, 19 Jun 2023 23:16:26 +0000 (18:16 -0500)
Fix potential dereference of ERR_PTR @tlink as reported by kernel test
robot

  fs/smb/client/connect.c:2775 cifs_match_super() error: 'tlink'
  dereferencing possible ERR_PTR()

Link: https://lore.kernel.org/all/202306170124.CtQqzf0I-lkp@intel.com/
Signed-off-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/connect.c

index 9d16626..f9e0b59 100644 (file)
@@ -2767,8 +2767,9 @@ cifs_match_super(struct super_block *sb, void *data)
        }
 
        tlink = cifs_get_tlink(cifs_sb_master_tlink(cifs_sb));
-       if (tlink == NULL) {
-               /* can not match superblock if tlink were ever null */
+       if (IS_ERR_OR_NULL(tlink)) {
+               pr_warn_once("%s: skip super matching due to bad tlink(%p)\n",
+                            __func__, tlink);
                spin_unlock(&cifs_tcp_ses_lock);
                return 0;
        }