All of lore.kernel.org
 help / color / mirror / Atom feed
* [brauner:cache_files 1/1] fs/cachefiles/bind.c:119:2: warning: variable 'root' is used uninitialized whenever 'if' condition is true
@ 2021-03-16 13:20 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2021-03-16 13:20 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 9004 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git cache_files
head:   c9c53507520b2eb523a0ac7102a89bf3b960e4be
commit: c9c53507520b2eb523a0ac7102a89bf3b960e4be [1/1] cachefiles: do not yet allow on idmapped mounts
config: powerpc64-randconfig-r005-20210316 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 50c7504a93fdb90c26870db8c8ea7add895c7725)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install powerpc64 cross compiling tool for clang build
        # apt-get install binutils-powerpc64-linux-gnu
        # https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git/commit/?id=c9c53507520b2eb523a0ac7102a89bf3b960e4be
        git remote add brauner https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git
        git fetch --no-tags brauner cache_files
        git checkout c9c53507520b2eb523a0ac7102a89bf3b960e4be
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> fs/cachefiles/bind.c:119:2: warning: variable 'root' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (mnt_user_ns(path.mnt) != &init_user_ns)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:56:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:58:30: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/cachefiles/bind.c:247:7: note: uninitialized use occurs here
           dput(root);
                ^~~~
   fs/cachefiles/bind.c:119:2: note: remove the 'if' if its condition is always false
           if (mnt_user_ns(path.mnt) != &init_user_ns)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:56:23: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                         ^
   fs/cachefiles/bind.c:86:44: note: initialize the variable 'root' to silence this warning
           struct dentry *graveyard, *cachedir, *root;
                                                     ^
                                                      = NULL
   1 warning generated.


vim +119 fs/cachefiles/bind.c

    77	
    78	/*
    79	 * add a cache
    80	 */
    81	static int cachefiles_daemon_add_cache(struct cachefiles_cache *cache)
    82	{
    83		struct cachefiles_object *fsdef;
    84		struct path path;
    85		struct kstatfs stats;
    86		struct dentry *graveyard, *cachedir, *root;
    87		const struct cred *saved_cred;
    88		int ret;
    89	
    90		_enter("");
    91	
    92		/* we want to work under the module's security ID */
    93		ret = cachefiles_get_security_ID(cache);
    94		if (ret < 0)
    95			return ret;
    96	
    97		cachefiles_begin_secure(cache, &saved_cred);
    98	
    99		/* allocate the root index object */
   100		ret = -ENOMEM;
   101	
   102		fsdef = kmem_cache_alloc(cachefiles_object_jar, GFP_KERNEL);
   103		if (!fsdef)
   104			goto error_root_object;
   105	
   106		ASSERTCMP(fsdef->backer, ==, NULL);
   107	
   108		atomic_set(&fsdef->usage, 1);
   109		fsdef->type = FSCACHE_COOKIE_TYPE_INDEX;
   110	
   111		_debug("- fsdef %p", fsdef);
   112	
   113		/* look up the directory at the root of the cache */
   114		ret = kern_path(cache->rootdirname, LOOKUP_DIRECTORY, &path);
   115		if (ret < 0)
   116			goto error_open_root;
   117	
   118		ret = -EINVAL;
 > 119		if (mnt_user_ns(path.mnt) != &init_user_ns)
   120			goto error_unsupported;
   121	
   122		cache->mnt = path.mnt;
   123		root = path.dentry;
   124	
   125		/* check parameters */
   126		ret = -EOPNOTSUPP;
   127		if (d_is_negative(root) ||
   128		    !d_backing_inode(root)->i_op->lookup ||
   129		    !d_backing_inode(root)->i_op->mkdir ||
   130		    !(d_backing_inode(root)->i_opflags & IOP_XATTR) ||
   131		    !root->d_sb->s_op->statfs ||
   132		    !root->d_sb->s_op->sync_fs)
   133			goto error_unsupported;
   134	
   135		ret = -EROFS;
   136		if (sb_rdonly(root->d_sb))
   137			goto error_unsupported;
   138	
   139		/* determine the security of the on-disk cache as this governs
   140		 * security ID of files we create */
   141		ret = cachefiles_determine_cache_security(cache, root, &saved_cred);
   142		if (ret < 0)
   143			goto error_unsupported;
   144	
   145		/* get the cache size and blocksize */
   146		ret = vfs_statfs(&path, &stats);
   147		if (ret < 0)
   148			goto error_unsupported;
   149	
   150		ret = -ERANGE;
   151		if (stats.f_bsize <= 0)
   152			goto error_unsupported;
   153	
   154		ret = -EOPNOTSUPP;
   155		if (stats.f_bsize > PAGE_SIZE)
   156			goto error_unsupported;
   157	
   158		cache->bsize = stats.f_bsize;
   159		cache->bshift = 0;
   160		if (stats.f_bsize < PAGE_SIZE)
   161			cache->bshift = PAGE_SHIFT - ilog2(stats.f_bsize);
   162	
   163		_debug("blksize %u (shift %u)",
   164		       cache->bsize, cache->bshift);
   165	
   166		_debug("size %llu, avail %llu",
   167		       (unsigned long long) stats.f_blocks,
   168		       (unsigned long long) stats.f_bavail);
   169	
   170		/* set up caching limits */
   171		do_div(stats.f_files, 100);
   172		cache->fstop = stats.f_files * cache->fstop_percent;
   173		cache->fcull = stats.f_files * cache->fcull_percent;
   174		cache->frun  = stats.f_files * cache->frun_percent;
   175	
   176		_debug("limits {%llu,%llu,%llu} files",
   177		       (unsigned long long) cache->frun,
   178		       (unsigned long long) cache->fcull,
   179		       (unsigned long long) cache->fstop);
   180	
   181		stats.f_blocks >>= cache->bshift;
   182		do_div(stats.f_blocks, 100);
   183		cache->bstop = stats.f_blocks * cache->bstop_percent;
   184		cache->bcull = stats.f_blocks * cache->bcull_percent;
   185		cache->brun  = stats.f_blocks * cache->brun_percent;
   186	
   187		_debug("limits {%llu,%llu,%llu} blocks",
   188		       (unsigned long long) cache->brun,
   189		       (unsigned long long) cache->bcull,
   190		       (unsigned long long) cache->bstop);
   191	
   192		/* get the cache directory and check its type */
   193		cachedir = cachefiles_get_directory(cache, root, "cache");
   194		if (IS_ERR(cachedir)) {
   195			ret = PTR_ERR(cachedir);
   196			goto error_unsupported;
   197		}
   198	
   199		fsdef->dentry = cachedir;
   200		fsdef->fscache.cookie = NULL;
   201	
   202		ret = cachefiles_check_object_type(fsdef);
   203		if (ret < 0)
   204			goto error_unsupported;
   205	
   206		/* get the graveyard directory */
   207		graveyard = cachefiles_get_directory(cache, root, "graveyard");
   208		if (IS_ERR(graveyard)) {
   209			ret = PTR_ERR(graveyard);
   210			goto error_unsupported;
   211		}
   212	
   213		cache->graveyard = graveyard;
   214	
   215		/* publish the cache */
   216		fscache_init_cache(&cache->cache,
   217				   &cachefiles_cache_ops,
   218				   "%s",
   219				   fsdef->dentry->d_sb->s_id);
   220	
   221		fscache_object_init(&fsdef->fscache, &fscache_fsdef_index,
   222				    &cache->cache);
   223	
   224		ret = fscache_add_cache(&cache->cache, &fsdef->fscache, cache->tag);
   225		if (ret < 0)
   226			goto error_add_cache;
   227	
   228		/* done */
   229		set_bit(CACHEFILES_READY, &cache->flags);
   230		dput(root);
   231	
   232		pr_info("File cache on %s registered\n", cache->cache.identifier);
   233	
   234		/* check how much space the cache has */
   235		cachefiles_has_space(cache, 0, 0);
   236		cachefiles_end_secure(cache, saved_cred);
   237		return 0;
   238	
   239	error_add_cache:
   240		dput(cache->graveyard);
   241		cache->graveyard = NULL;
   242	error_unsupported:
   243		mntput(cache->mnt);
   244		cache->mnt = NULL;
   245		dput(fsdef->dentry);
   246		fsdef->dentry = NULL;
   247		dput(root);
   248	error_open_root:
   249		kmem_cache_free(cachefiles_object_jar, fsdef);
   250	error_root_object:
   251		cachefiles_end_secure(cache, saved_cred);
   252		pr_err("Failed to register: %d\n", ret);
   253		return ret;
   254	}
   255	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 36318 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-16 13:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-16 13:20 [brauner:cache_files 1/1] fs/cachefiles/bind.c:119:2: warning: variable 'root' is used uninitialized whenever 'if' condition is true kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.