fs/smb/client/ioctl.c:135:2-7: WARNING: NULL check before some freeing functions is not needed.

From: kernel test robot

Date: Sat Aug 15 2026 - 16:57:35 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 3eb40771c00a8488fa6ed2cc1fe203477908bf38
commit: 5693347de107a26f68d1f43b25ff2e348c7229a9 smb/client: use writable handle for FS_IOC_SETFLAGS compression
date: 9 weeks ago
config: powerpc-randconfig-r053-20260812 (https://download.01.org/0day-ci/archive/20260816/202608160402.0ffQDoCg-lkp@xxxxxxxxx/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 12df34b8469b8095359de8c249cb1b2753fadeea)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Fixes: 5693347de107 ("smb/client: use writable handle for FS_IOC_SETFLAGS compression")
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202608160402.0ffQDoCg-lkp@xxxxxxxxx/

cocci warnings: (new ones prefixed by >>)
>> fs/smb/client/ioctl.c:135:2-7: WARNING: NULL check before some freeing functions is not needed.

vim +135 fs/smb/client/ioctl.c

69
70 static int cifs_set_compression_by_path(unsigned int xid, struct file *filep,
71 struct cifs_tcon *tcon)
72 {
73 struct inode *inode = file_inode(filep);
74 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
75 struct TCP_Server_Info *server = tcon->ses->server;
76 struct cifs_open_parms oparms;
77 struct cifs_open_info_data data = {};
78 struct cifsFileInfo *tmp_cfile = NULL;
79 struct cifs_fid fid = {};
80 const char *full_path;
81 __u32 oplock = 0;
82 u64 uniqueid;
83 void *page;
84 int rc;
85
86 if (!server->ops->open || !server->ops->close ||
87 !server->ops->query_file_info)
88 return -EOPNOTSUPP;
89
90 if (!(cifs_sb_flags(cifs_sb) & CIFS_MOUNT_SERVER_INUM) ||
91 cifs_sb->mnt_cifs_serverino_autodisabled)
92 return -EOPNOTSUPP;
93
94 if (d_unhashed(filep->f_path.dentry))
95 return -ESTALE;
96
97 page = alloc_dentry_path();
98 full_path = build_path_from_dentry(filep->f_path.dentry, page);
99 if (IS_ERR(full_path)) {
100 free_dentry_path(page);
101 return PTR_ERR(full_path);
102 }
103
104 oparms = CIFS_OPARMS(cifs_sb, tcon, full_path, FILE_WRITE_DATA |
105 FILE_READ_ATTRIBUTES,
106 FILE_OPEN, 0, ACL_NO_MODE);
107 oparms.fid = &fid;
108
109 rc = server->ops->open(xid, &oparms, &oplock, NULL);
110 if (rc)
111 goto out;
112
113 tmp_cfile = kzalloc_obj(*tmp_cfile);
114 if (!tmp_cfile) {
115 rc = -ENOMEM;
116 goto close;
117 }
118
119 tmp_cfile->fid = fid;
120 rc = server->ops->query_file_info(xid, tcon, tmp_cfile, &data);
121 if (rc)
122 goto close;
123
124 uniqueid = le64_to_cpu(data.fi.IndexNumber);
125 if (uniqueid != CIFS_I(inode)->uniqueid) {
126 rc = -ESTALE;
127 goto close;
128 }
129
130 rc = server->ops->set_compression(xid, tcon, tmp_cfile);
131
132 close:
133 server->ops->close(xid, tcon, &fid);
134 if (tmp_cfile)
> 135 kfree(tmp_cfile);
136 cifs_free_open_info(&data);
137 out:
138 free_dentry_path(page);
139 return rc;
140 }
141

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki