fs/nilfs2/namei.c:261 nilfs_mkdir() warn: passing zero to 'ERR_PTR'

kernel test robot
2026-03-30T10:20:54Z

head: 7aaa8047eafd0bd628065b15757d9b48c5f9c07d
commit: 88d5baf69082e5b410296435008329676b687549 Change inode_operations.mkdir to return struct dentry *
date: 1 year, 1 month ago
:::::: branch date: 12 hours ago
:::::: commit date: 1 year, 1 month ago
config: arc-randconfig-r071-20260330 (https://download.01.org/0day-ci/archive/20260330/202603301823.9YkGdk2Z-lkp@intel.com/config)
compiler: arc-linux-gcc (GCC) 13.4.0
smatch: v0.5.0-9004-gb810ac53

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 <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202603301823.9YkGdk2Z-lkp@intel.com/

smatch warnings:
fs/nilfs2/namei.c:261 nilfs_mkdir() warn: passing zero to 'ERR_PTR'

vim +/ERR_PTR +261 fs/nilfs2/namei.c

d25006523d0b9e Ryusuke Konishi 2009-04-06 220
88d5baf69082e5 NeilBrown 2025-02-27 221 static struct dentry *nilfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
549c7297717c32 Christian Brauner 2021-01-21 222 struct dentry *dentry, umode_t mode)
d25006523d0b9e Ryusuke Konishi 2009-04-06 223 {
d25006523d0b9e Ryusuke Konishi 2009-04-06 224 struct inode *inode;
d25006523d0b9e Ryusuke Konishi 2009-04-06 225 struct nilfs_transaction_info ti;
47420c799830d4 Ryusuke Konishi 2009-04-06 226 int err;
d25006523d0b9e Ryusuke Konishi 2009-04-06 227
d25006523d0b9e Ryusuke Konishi 2009-04-06 228 err = nilfs_transaction_begin(dir->i_sb, &ti, 1);
d25006523d0b9e Ryusuke Konishi 2009-04-06 229 if (err)
88d5baf69082e5 NeilBrown 2025-02-27 230 return ERR_PTR(err);
d25006523d0b9e Ryusuke Konishi 2009-04-06 231
565de406e7bfa9 Jiro SEKIBA 2009-11-27 232 inc_nlink(dir);
d25006523d0b9e Ryusuke Konishi 2009-04-06 233
d25006523d0b9e Ryusuke Konishi 2009-04-06 234 inode = nilfs_new_inode(dir, S_IFDIR | mode);
d25006523d0b9e Ryusuke Konishi 2009-04-06 235 err = PTR_ERR(inode);
d25006523d0b9e Ryusuke Konishi 2009-04-06 236 if (IS_ERR(inode))
d25006523d0b9e Ryusuke Konishi 2009-04-06 237 goto out_dir;
d25006523d0b9e Ryusuke Konishi 2009-04-06 238
d25006523d0b9e Ryusuke Konishi 2009-04-06 239 inode->i_op = &nilfs_dir_inode_operations;
d25006523d0b9e Ryusuke Konishi 2009-04-06 240 inode->i_fop = &nilfs_dir_operations;
d25006523d0b9e Ryusuke Konishi 2009-04-06 241 inode->i_mapping->a_ops = &nilfs_aops;
d25006523d0b9e Ryusuke Konishi 2009-04-06 242
565de406e7bfa9 Jiro SEKIBA 2009-11-27 243 inc_nlink(inode);
d25006523d0b9e Ryusuke Konishi 2009-04-06 244
d25006523d0b9e Ryusuke Konishi 2009-04-06 245 err = nilfs_make_empty(inode, dir);
d25006523d0b9e Ryusuke Konishi 2009-04-06 246 if (err)
d25006523d0b9e Ryusuke Konishi 2009-04-06 247 goto out_fail;
d25006523d0b9e Ryusuke Konishi 2009-04-06 248
d25006523d0b9e Ryusuke Konishi 2009-04-06 249 err = nilfs_add_link(dentry, inode);
d25006523d0b9e Ryusuke Konishi 2009-04-06 250 if (err)
d25006523d0b9e Ryusuke Konishi 2009-04-06 251 goto out_fail;
d25006523d0b9e Ryusuke Konishi 2009-04-06 252
abdb318b79d387 Jiro SEKIBA 2009-11-27 253 nilfs_mark_inode_dirty(inode);
1e2e547a93a00e Al Viro 2018-05-04 254 d_instantiate_new(dentry, inode);
d25006523d0b9e Ryusuke Konishi 2009-04-06 255 out:
47420c799830d4 Ryusuke Konishi 2009-04-06 256 if (!err)
47420c799830d4 Ryusuke Konishi 2009-04-06 257 err = nilfs_transaction_commit(dir->i_sb);
47420c799830d4 Ryusuke Konishi 2009-04-06 258 else
47420c799830d4 Ryusuke Konishi 2009-04-06 259 nilfs_transaction_abort(dir->i_sb);
47420c799830d4 Ryusuke Konishi 2009-04-06 260
88d5baf69082e5 NeilBrown 2025-02-27 @261 return ERR_PTR(err);
d25006523d0b9e Ryusuke Konishi 2009-04-06 262
d25006523d0b9e Ryusuke Konishi 2009-04-06 263 out_fail:
565de406e7bfa9 Jiro SEKIBA 2009-11-27 264 drop_nlink(inode);
565de406e7bfa9 Jiro SEKIBA 2009-11-27 265 drop_nlink(inode);
abdb318b79d387 Jiro SEKIBA 2009-11-27 266 nilfs_mark_inode_dirty(inode);
705304a863cc41 Ryusuke Konishi 2014-12-10 267 unlock_new_inode(inode);
d25006523d0b9e Ryusuke Konishi 2009-04-06 268 iput(inode);
d25006523d0b9e Ryusuke Konishi 2009-04-06 269 out_dir:
565de406e7bfa9 Jiro SEKIBA 2009-11-27 270 drop_nlink(dir);
abdb318b79d387 Jiro SEKIBA 2009-11-27 271 nilfs_mark_inode_dirty(dir);
d25006523d0b9e Ryusuke Konishi 2009-04-06 272 goto out;
d25006523d0b9e Ryusuke Konishi 2009-04-06 273 }
d25006523d0b9e Ryusuke Konishi 2009-04-06 274