[bug report] CIFS: Migrate to shared superblock model

Dan Carpenter
2021-09-21T20:36:37Z

[ Ancient code before of the rename ]

Hello Samba devs,

The patch 25c7f41e9234: "CIFS: Migrate to shared superblock model"
from May 26, 2011, leads to the following
Smatch static checker warning:

fs/smbfs_client/connect.c:2392 cifs_match_super()
warn: 'tlink' isn't an ERR_PTR

fs/smbfs_client/connect.c
2377 int
2378 cifs_match_super(struct super_block *sb, void *data)
2379 {
2380 struct cifs_mnt_data *mnt_data = (struct cifs_mnt_data *)data;
2381 struct smb3_fs_context *ctx;
2382 struct cifs_sb_info *cifs_sb;
2383 struct TCP_Server_Info *tcp_srv;
2384 struct cifs_ses *ses;
2385 struct cifs_tcon *tcon;
2386 struct tcon_link *tlink;
2387 int rc = 0;
2388
2389 spin_lock(&cifs_tcp_ses_lock);
2390 cifs_sb = CIFS_SB(sb);
2391 tlink = cifs_get_tlink(cifs_sb_master_tlink(cifs_sb));
--> 2392 if (IS_ERR(tlink)) {

cifs_sb_master_tlink() doesn't return error pointers. Smatch thinks it
might return NULL though. Hard to tell. NULL would crash.

2393 spin_unlock(&cifs_tcp_ses_lock);
2394 return rc;
2395 }
2396 tcon = tlink_tcon(tlink);

regards,
dan carpenter