* [chrome-os:chromeos-6.1 36/42] fs/configfs/inode.c:189 configfs_create() error: we previously assumed 'sd_parent' could be null (see line 182)
@ 2023-08-11 5:22 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2023-08-11 5:22 UTC (permalink / raw)
To: oe-kbuild, cros-kernel-buildreports, Guenter Roeck; +Cc: lkp, oe-kbuild-all
tree: https://chromium.googlesource.com/chromiumos/third_party/kernel chromeos-6.1
head: 49642342732c55841e454f874f36062a1a64e0dd
commit: 6570cb0654b65ea2dbe52c1c0f2590e338d9ab7e [36/42] FIXUP: CHROMIUM: configfs: inherit file and directory owners
config: arc-randconfig-m041-20230811 (https://download.01.org/0day-ci/archive/20230811/202308110932.apiJRvXa-lkp@intel.com/config)
compiler: arceb-elf-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230811/202308110932.apiJRvXa-lkp@intel.com/reproduce)
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
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202308110932.apiJRvXa-lkp@intel.com/
smatch warnings:
fs/configfs/inode.c:189 configfs_create() error: we previously assumed 'sd_parent' could be null (see line 182)
vim +/sd_parent +189 fs/configfs/inode.c
2743c515a1239b Al Viro 2019-09-11 157 struct inode *configfs_create(struct dentry *dentry, umode_t mode)
7063fbf2261194 Joel Becker 2005-12-15 158 {
7063fbf2261194 Joel Becker 2005-12-15 159 struct inode *inode = NULL;
16d13b59b5b85e Al Viro 2012-03-17 160 struct configfs_dirent *sd;
16d13b59b5b85e Al Viro 2012-03-17 161 struct inode *p_inode;
e5e090ca97600b Daniel Rosenberg 2018-03-15 162 struct dentry *parent;
16d13b59b5b85e Al Viro 2012-03-17 163
16d13b59b5b85e Al Viro 2012-03-17 164 if (!dentry)
2743c515a1239b Al Viro 2019-09-11 165 return ERR_PTR(-ENOENT);
16d13b59b5b85e Al Viro 2012-03-17 166
2b0143b5c986be David Howells 2015-03-17 167 if (d_really_is_positive(dentry))
2743c515a1239b Al Viro 2019-09-11 168 return ERR_PTR(-EEXIST);
16d13b59b5b85e Al Viro 2012-03-17 169
16d13b59b5b85e Al Viro 2012-03-17 170 sd = dentry->d_fsdata;
e5e090ca97600b Daniel Rosenberg 2018-03-15 171 parent = dget_parent(dentry);
e5e090ca97600b Daniel Rosenberg 2018-03-15 172 if (parent && !sd->s_iattr) {
6570cb0654b65e Tzung-Bi Shih 2023-08-09 173 struct configfs_dirent *sd_parent = parent->d_fsdata;
6570cb0654b65e Tzung-Bi Shih 2023-08-09 174
6570cb0654b65e Tzung-Bi Shih 2023-08-09 175 sd->s_iattr = kzalloc(sizeof(struct iattr), GFP_KERNEL);
36caf34d422a0c Tzung-Bi Shih 2023-08-09 176 if (!sd->s_iattr) {
36caf34d422a0c Tzung-Bi Shih 2023-08-09 177 dput(parent);
e5e090ca97600b Daniel Rosenberg 2018-03-15 178 return ERR_PTR(-ENOMEM);
e5e090ca97600b Daniel Rosenberg 2018-03-15 179 }
6570cb0654b65e Tzung-Bi Shih 2023-08-09 180
6570cb0654b65e Tzung-Bi Shih 2023-08-09 181 sd->s_iattr->ia_mode = sd->s_mode;
6570cb0654b65e Tzung-Bi Shih 2023-08-09 @182 if (sd_parent && sd_parent->s_iattr) {
^^^^^^^^^
this assumes sd_parent can be NULL
6570cb0654b65e Tzung-Bi Shih 2023-08-09 183 sd->s_iattr->ia_uid = sd_parent->s_iattr->ia_uid;
6570cb0654b65e Tzung-Bi Shih 2023-08-09 184 sd->s_iattr->ia_gid = sd_parent->s_iattr->ia_gid;
6570cb0654b65e Tzung-Bi Shih 2023-08-09 185 } else {
6570cb0654b65e Tzung-Bi Shih 2023-08-09 186 sd->s_iattr->ia_uid = GLOBAL_ROOT_UID;
6570cb0654b65e Tzung-Bi Shih 2023-08-09 187 sd->s_iattr->ia_gid = GLOBAL_ROOT_GID;
6570cb0654b65e Tzung-Bi Shih 2023-08-09 188 }
6570cb0654b65e Tzung-Bi Shih 2023-08-09 @189 if (sd_parent->s_dentry && d_inode(sd_parent->s_dentry))
^^^^^^^^^^^^^^^^^^^
unchecked dereference
6570cb0654b65e Tzung-Bi Shih 2023-08-09 190 sd->s_iattr->ia_ctime = current_time(d_inode(sd_parent->s_dentry));
6570cb0654b65e Tzung-Bi Shih 2023-08-09 191 else
6570cb0654b65e Tzung-Bi Shih 2023-08-09 192 ktime_get_coarse_real_ts64(&sd->s_iattr->ia_ctime);
6570cb0654b65e Tzung-Bi Shih 2023-08-09 193 sd->s_iattr->ia_atime = sd->s_iattr->ia_mtime = sd->s_iattr->ia_ctime;
36caf34d422a0c Tzung-Bi Shih 2023-08-09 194 }
e5e090ca97600b Daniel Rosenberg 2018-03-15 195 dput(parent);
16d13b59b5b85e Al Viro 2012-03-17 196 inode = configfs_new_inode(mode, sd, dentry->d_sb);
16d13b59b5b85e Al Viro 2012-03-17 197 if (!inode)
2743c515a1239b Al Viro 2019-09-11 198 return ERR_PTR(-ENOMEM);
16d13b59b5b85e Al Viro 2012-03-17 199
2b0143b5c986be David Howells 2015-03-17 200 p_inode = d_inode(dentry->d_parent);
c2050a454c7f12 Deepa Dinamani 2016-09-14 201 p_inode->i_mtime = p_inode->i_ctime = current_time(p_inode);
e74cc06df3b05e Louis Rilling 2009-01-28 202 configfs_set_inode_lock_class(sd, inode);
2743c515a1239b Al Viro 2019-09-11 203 return inode;
7063fbf2261194 Joel Becker 2005-12-15 204 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-08-11 5:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-11 5:22 [chrome-os:chromeos-6.1 36/42] fs/configfs/inode.c:189 configfs_create() error: we previously assumed 'sd_parent' could be null (see line 182) Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).