public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
* [samba-ksmbd:for-next 2/2] fs/smb/client/ioctl.c:178:6: warning: variable 'flags' is used uninitialized whenever 'if' condition is true
@ 2024-07-30 18:00 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2024-07-30 18:00 UTC (permalink / raw)
  To: Steve French; +Cc: llvm, oe-kbuild-all

tree:   git://git.samba.org/ksmbd.git for-next
head:   0aeae343da69af8c0516b6650312be517d4ff6a8
commit: 0aeae343da69af8c0516b6650312be517d4ff6a8 [2/2] smb3: add dynamic tracepoints for shutdown ioctl
config: x86_64-rhel-8.3-rust (https://download.01.org/0day-ci/archive/20240731/202407310110.dsjyb2uc-lkp@intel.com/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240731/202407310110.dsjyb2uc-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/202407310110.dsjyb2uc-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> fs/smb/client/ioctl.c:178:6: warning: variable 'flags' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
     178 |         if (!capable(CAP_SYS_ADMIN)) {
         |             ^~~~~~~~~~~~~~~~~~~~~~~
   fs/smb/client/ioctl.c:236:30: note: uninitialized use occurs here
     236 |         trace_smb3_shutdown_err(rc, flags, tcon->tid);
         |                                     ^~~~~
   fs/smb/client/ioctl.c:178:2: note: remove the 'if' if its condition is always false
     178 |         if (!capable(CAP_SYS_ADMIN)) {
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     179 |                 rc = -EPERM;
         |                 ~~~~~~~~~~~~
     180 |                 goto shutdown_out_err;
         |                 ~~~~~~~~~~~~~~~~~~~~~~
     181 |         }
         |         ~
   fs/smb/client/ioctl.c:175:13: note: initialize the variable 'flags' to silence this warning
     175 |         __u32 flags;
         |                    ^
         |                     = 0
>> fs/smb/client/ioctl.c:178:6: warning: variable 'tcon' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
     178 |         if (!capable(CAP_SYS_ADMIN)) {
         |             ^~~~~~~~~~~~~~~~~~~~~~~
   fs/smb/client/ioctl.c:236:37: note: uninitialized use occurs here
     236 |         trace_smb3_shutdown_err(rc, flags, tcon->tid);
         |                                            ^~~~
   fs/smb/client/ioctl.c:178:2: note: remove the 'if' if its condition is always false
     178 |         if (!capable(CAP_SYS_ADMIN)) {
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     179 |                 rc = -EPERM;
         |                 ~~~~~~~~~~~~
     180 |                 goto shutdown_out_err;
         |                 ~~~~~~~~~~~~~~~~~~~~~~
     181 |         }
         |         ~
   fs/smb/client/ioctl.c:174:24: note: initialize the variable 'tcon' to silence this warning
     174 |         struct cifs_tcon *tcon;
         |                               ^
         |                                = NULL
   2 warnings generated.


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

   169	
   170	static int cifs_shutdown(struct super_block *sb, unsigned long arg)
   171	{
   172		struct cifs_sb_info *sbi = CIFS_SB(sb);
   173		struct tcon_link *tlink;
   174		struct cifs_tcon *tcon;
 > 175		__u32 flags;
   176		int rc;
   177	
 > 178		if (!capable(CAP_SYS_ADMIN)) {
   179			rc = -EPERM;
   180			goto shutdown_out_err;
   181		}
   182	
   183		if (get_user(flags, (__u32 __user *)arg))
   184			return -EFAULT;
   185	
   186		tlink = cifs_sb_tlink(sbi);
   187		if (IS_ERR(tlink))
   188			return PTR_ERR(tlink);
   189		tcon = tlink_tcon(tlink);
   190	
   191		trace_smb3_shutdown_enter(flags, tcon->tid);
   192		if (flags > CIFS_GOING_FLAGS_NOLOGFLUSH) {
   193			rc = -EINVAL;
   194			goto shutdown_out_err;
   195		}
   196	
   197		if (cifs_forced_shutdown(sbi))
   198			goto shutdown_good;
   199	
   200		cifs_dbg(VFS, "shut down requested (%d)", flags);
   201	
   202		/*
   203		 * see:
   204		 *   https://man7.org/linux/man-pages/man2/ioctl_xfs_goingdown.2.html
   205		 * for more information and description of original intent of the flags
   206		 */
   207		switch (flags) {
   208		/*
   209		 * We could add support later for default flag which requires:
   210		 *     "Flush all dirty data and metadata to disk"
   211		 * would need to call syncfs or equivalent to flush page cache for
   212		 * the mount and then issue fsync to server (if nostrictsync not set)
   213		 */
   214		case CIFS_GOING_FLAGS_DEFAULT:
   215			cifs_dbg(FYI, "shutdown with default flag not supported\n");
   216			rc = -EINVAL;
   217			goto shutdown_out_err;
   218		/*
   219		 * FLAGS_LOGFLUSH is easy since it asks to write out metadata (not
   220		 * data) but metadata writes are not cached on the client, so can treat
   221		 * it similarly to NOLOGFLUSH
   222		 */
   223		case CIFS_GOING_FLAGS_LOGFLUSH:
   224		case CIFS_GOING_FLAGS_NOLOGFLUSH:
   225			sbi->mnt_cifs_flags |= CIFS_MOUNT_SHUTDOWN;
   226			goto shutdown_good;
   227		default:
   228			rc = -EINVAL;
   229			goto shutdown_out_err;
   230		}
   231	
   232	shutdown_good:
   233		trace_smb3_shutdown_done(flags, tcon->tid);
   234		return 0;
   235	shutdown_out_err:
   236		trace_smb3_shutdown_err(rc, flags, tcon->tid);
   237		return rc;
   238	}
   239	

-- 
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:[~2024-07-30 18:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-30 18:00 [samba-ksmbd:for-next 2/2] fs/smb/client/ioctl.c:178:6: warning: variable 'flags' is used uninitialized whenever 'if' condition is true kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox