llvm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Christian Brauner <brauner@kernel.org>
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
	Christian Brauner <christianvanbrauner@gmail.com>
Subject: [brauner-github:work.fd.prepare 31/43] fs/namespace.c:4376:2: warning: variable 'file' is uninitialized when used here
Date: Wed, 19 Nov 2025 01:39:01 +0800	[thread overview]
Message-ID: <202511190132.8nRAlAZI-lkp@intel.com> (raw)

tree:   https://github.com/brauner/linux.git work.fd.prepare
head:   7eb06f9f7a76175a82d3c6b9d94219d7b64b6bce
commit: 7a6aae3e938ed79442f55c1f2b6d4a73a2cf0c51 [31/43] fs: namespace
config: arm-allnoconfig (https://download.01.org/0day-ci/archive/20251119/202511190132.8nRAlAZI-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 0bba1e76581bad04e7d7f09f5115ae5e2989e0d9)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251119/202511190132.8nRAlAZI-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>
| Closes: https://lore.kernel.org/oe-kbuild-all/202511190132.8nRAlAZI-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> fs/namespace.c:4376:2: warning: variable 'file' is uninitialized when used here [-Wuninitialized]
    4376 |         file->f_mode |= FMODE_NEED_UNMOUNT;
         |         ^~~~
   fs/namespace.c:4281:19: note: initialize the variable 'file' to silence this warning
    4281 |         struct file *file;
         |                          ^
         |                           = NULL
   fs/namespace.c:96:1: warning: unused function 'class_namespace_excl_lock_err' [-Wunused-function]
      96 | DEFINE_LOCK_GUARD_0(namespace_excl, namespace_lock(), namespace_unlock())
         | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/cleanup.h:521:49: note: expanded from macro 'DEFINE_LOCK_GUARD_0'
     521 | __DEFINE_CLASS_IS_CONDITIONAL(_name, false);                            \
         |                                                                         ^
     522 | __DEFINE_UNLOCK_GUARD(_name, void, _unlock, __VA_ARGS__)                \
         | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/cleanup.h:495:10: note: expanded from macro '\
   __DEFINE_UNLOCK_GUARD'
     495 |                                                                         \
         |                                                                         ^
     496 | __DEFINE_GUARD_LOCK_PTR(_name, &_T->lock)
         | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/cleanup.h:380:20: note: expanded from macro '\
   __DEFINE_GUARD_LOCK_PTR'
     380 |         static inline int class_##_name##_lock_err(class_##_name##_t *_T)   \
         |                           ^~~~~~~~~~~~~~~~~~~~~~~~
   <scratch space>:105:1: note: expanded from here
     105 | class_namespace_excl_lock_err
         | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/namespace.c:97:1: warning: unused function 'class_namespace_shared_lock_err' [-Wunused-function]
      97 | DEFINE_LOCK_GUARD_0(namespace_shared, down_read(&namespace_sem),
         | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      98 |                                       up_read(&namespace_sem))
         |                                       ~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/cleanup.h:521:49: note: expanded from macro 'DEFINE_LOCK_GUARD_0'
     521 | __DEFINE_CLASS_IS_CONDITIONAL(_name, false);                            \
         |                                                                         ^
     522 | __DEFINE_UNLOCK_GUARD(_name, void, _unlock, __VA_ARGS__)                \
         | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/cleanup.h:495:10: note: expanded from macro '\
   __DEFINE_UNLOCK_GUARD'
     495 |                                                                         \
         |                                                                         ^
     496 | __DEFINE_GUARD_LOCK_PTR(_name, &_T->lock)
         | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/cleanup.h:380:20: note: expanded from macro '\
   __DEFINE_GUARD_LOCK_PTR'
     380 |         static inline int class_##_name##_lock_err(class_##_name##_t *_T)   \
         |                           ^~~~~~~~~~~~~~~~~~~~~~~~
   <scratch space>:127:1: note: expanded from here
     127 | class_namespace_shared_lock_err
         | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/namespace.c:135:37: warning: unused function 'node_to_mnt_ns' [-Wunused-function]
     135 | static inline struct mnt_namespace *node_to_mnt_ns(const struct rb_node *node)
         |                                     ^~~~~~~~~~~~~~
   4 warnings generated.


vim +/file +4376 fs/namespace.c

  4271	
  4272	/*
  4273	 * Create a kernel mount representation for a new, prepared superblock
  4274	 * (specified by fs_fd) and attach to an open_tree-like file descriptor.
  4275	 */
  4276	SYSCALL_DEFINE3(fsmount, int, fs_fd, unsigned int, flags,
  4277			unsigned int, attr_flags)
  4278	{
  4279		struct mnt_namespace *ns;
  4280		struct fs_context *fc;
  4281		struct file *file;
  4282		struct path newmount __free(path_put) = {};
  4283		struct mount *mnt;
  4284		unsigned int mnt_flags = 0;
  4285		long ret;
  4286	
  4287		if (!may_mount())
  4288			return -EPERM;
  4289	
  4290		if ((flags & ~(FSMOUNT_CLOEXEC)) != 0)
  4291			return -EINVAL;
  4292	
  4293		if (attr_flags & ~FSMOUNT_VALID_FLAGS)
  4294			return -EINVAL;
  4295	
  4296		mnt_flags = attr_flags_to_mnt_flags(attr_flags);
  4297	
  4298		switch (attr_flags & MOUNT_ATTR__ATIME) {
  4299		case MOUNT_ATTR_STRICTATIME:
  4300			break;
  4301		case MOUNT_ATTR_NOATIME:
  4302			mnt_flags |= MNT_NOATIME;
  4303			break;
  4304		case MOUNT_ATTR_RELATIME:
  4305			mnt_flags |= MNT_RELATIME;
  4306			break;
  4307		default:
  4308			return -EINVAL;
  4309		}
  4310	
  4311		CLASS(fd, f)(fs_fd);
  4312		if (fd_empty(f))
  4313			return -EBADF;
  4314	
  4315		if (fd_file(f)->f_op != &fscontext_fops)
  4316			return -EINVAL;
  4317	
  4318		fc = fd_file(f)->private_data;
  4319	
  4320		ACQUIRE(mutex_intr, uapi_mutex)(&fc->uapi_mutex);
  4321		ret = ACQUIRE_ERR(mutex_intr, &uapi_mutex);
  4322		if (ret)
  4323			return ret;
  4324	
  4325		/* There must be a valid superblock or we can't mount it */
  4326		ret = -EINVAL;
  4327		if (!fc->root)
  4328			return ret;
  4329	
  4330		ret = -EPERM;
  4331		if (mount_too_revealing(fc->root->d_sb, &mnt_flags)) {
  4332			errorfcp(fc, "VFS", "Mount too revealing");
  4333			return ret;
  4334		}
  4335	
  4336		ret = -EBUSY;
  4337		if (fc->phase != FS_CONTEXT_AWAITING_MOUNT)
  4338			return ret;
  4339	
  4340		if (fc->sb_flags & SB_MANDLOCK)
  4341			warn_mandlock();
  4342	
  4343		newmount.mnt = vfs_create_mount(fc);
  4344		if (IS_ERR(newmount.mnt))
  4345			return PTR_ERR(newmount.mnt);
  4346		newmount.dentry = dget(fc->root);
  4347		newmount.mnt->mnt_flags = mnt_flags;
  4348	
  4349		/* We've done the mount bit - now move the file context into more or
  4350		 * less the same state as if we'd done an fspick().  We don't want to
  4351		 * do any memory allocation or anything like that at this point as we
  4352		 * don't want to have to handle any errors incurred.
  4353		 */
  4354		vfs_clean_context(fc);
  4355	
  4356		ns = alloc_mnt_ns(current->nsproxy->mnt_ns->user_ns, true);
  4357		if (IS_ERR(ns))
  4358			return PTR_ERR(ns);
  4359		mnt = real_mount(newmount.mnt);
  4360		ns->root = mnt;
  4361		ns->nr_mounts = 1;
  4362		mnt_add_to_ns(ns, mnt);
  4363		mntget(newmount.mnt);
  4364	
  4365		FD_PREPARE(fdprep, (flags & FSMOUNT_CLOEXEC) ? O_CLOEXEC : 0,
  4366			   dentry_open(&newmount, O_PATH, fc->cred));
  4367		if (fd_prepare_failed(fdprep)) {
  4368			dissolve_on_fput(newmount.mnt);
  4369			return fd_prepare_error(fdprep);
  4370		}
  4371	
  4372		/*
  4373		 * Attach to an apparent O_PATH fd with a note that we
  4374		 * need to unmount it, not just simply put it.
  4375		 */
> 4376		file->f_mode |= FMODE_NEED_UNMOUNT;
  4377		return fd_publish(fdprep);
  4378	}
  4379	

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

                 reply	other threads:[~2025-11-18 17:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202511190132.8nRAlAZI-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=brauner@kernel.org \
    --cc=christianvanbrauner@gmail.com \
    --cc=llvm@lists.linux.dev \
    --cc=oe-kbuild-all@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).