Skip to contentSkip to conversation

fs/cachefiles/namei.c:300 cachefiles_walk_to_object() warn: signedness bug returning '(-105)'

PATCH New Dan Carpenter 1 participant 1 message May 23, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 21/61 fs/cachefiles/namei.c:300 cachefiles_walk_to_object() warn: signedness bug returning '(-105)'

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git fscache-iter
head:   59f33c90ef6c1a75d4af75e5f60d98c0d965b6a2
commit: 667b9011d562075c1d4e831862efa31f2f47fba0 [21/61] fscache: Replace the object management state machine

compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build):

        git checkout 667b9011d562075c1d4e831862efa31f2f47fba0
        # save the attached .config to linux build tree
        make ARCH=i386 

If you fix the issue, kindly add following tag as appropriate

New smatch warnings:
fs/cachefiles/namei.c:300 cachefiles_walk_to_object() warn: signedness bug returning '(-105)' fs/fscache/obj.c:27 fscache_do_alloc_object() warn: argument 2 to %lx specifier is cast from pointer

# https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/commit/?id=667b9011d562075c1d4e831862efa31f2f47fba0
git remote add dhowells-fs https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git
git remote update dhowells-fs
git checkout 667b9011d562075c1d4e831862efa31f2f47fba0
vim +300 fs/cachefiles/namei.c

667b9011d56207 David Howells 2020-02-06 273 bool cachefiles_walk_to_object(struct cachefiles_object *parent,

                                                 ^^^^

bool

9ae326a69004de David Howells    2009-04-03  274  			       struct cachefiles_object *object,
5c65c4e759eafd David Howells    2020-02-06  275  			       const char *key)
9ae326a69004de David Howells    2009-04-03  276  {
9ae326a69004de David Howells    2009-04-03  277  	struct cachefiles_cache *cache;
9ae326a69004de David Howells    2009-04-03  278  	struct dentry *dir, *next = NULL;
a18feb55769b70 David Howells    2018-04-04  279  	struct inode *inode;
821404434f3324 David Howells    2010-12-24  280  	struct path path;
9ae326a69004de David Howells    2009-04-03  281  	unsigned long start;
9ae326a69004de David Howells    2009-04-03  282  	const char *name;
667b9011d56207 David Howells    2020-02-06  283  	bool marked = false, negated = false;
9ae326a69004de David Howells    2009-04-03  284  	int ret, nlen;
9ae326a69004de David Howells    2009-04-03  285  
c61ea31dac0319 David Howells    2010-05-11  286  	_enter("OBJ%x{%p},OBJ%x,%s,",
c61ea31dac0319 David Howells    2010-05-11  287  	       parent->fscache.debug_id, parent->dentry,
c61ea31dac0319 David Howells    2010-05-11  288  	       object->fscache.debug_id, key);
9ae326a69004de David Howells    2009-04-03  289  
9ae326a69004de David Howells    2009-04-03  290  	cache = container_of(parent->fscache.cache,
9ae326a69004de David Howells    2009-04-03  291  			     struct cachefiles_cache, cache);
821404434f3324 David Howells    2010-12-24  292  	path.mnt = cache->mnt;
9ae326a69004de David Howells    2009-04-03  293  
9ae326a69004de David Howells    2009-04-03  294  	ASSERT(parent->dentry);
466b77bc954c23 David Howells    2015-03-17  295  	ASSERT(d_backing_inode(parent->dentry));
9ae326a69004de David Howells    2009-04-03  296  
e36cb0b89ce20b David Howells    2015-01-29  297  	if (!(d_is_dir(parent->dentry))) {
9ae326a69004de David Howells    2009-04-03  298  		// TODO: convert file to dir
9ae326a69004de David Howells    2009-04-03  299  		_leave("looking up in none directory");
9ae326a69004de David Howells    2009-04-03 @300  		return -ENOBUFS;
                                                                       ^^^^^^^^

Negative error code.

9ae326a69004de David Howells    2009-04-03  301  	}
9ae326a69004de David Howells    2009-04-03  302  
9ae326a69004de David Howells    2009-04-03  303  	dir = dget(parent->dentry);
9ae326a69004de David Howells    2009-04-03  304  
9ae326a69004de David Howells    2009-04-03  305  advance:
9ae326a69004de David Howells    2009-04-03  306  	/* attempt to transit the first directory component */
9ae326a69004de David Howells    2009-04-03  307  	name = key;
9ae326a69004de David Howells    2009-04-03  308  	nlen = strlen(key);
9ae326a69004de David Howells    2009-04-03  309  
9ae326a69004de David Howells    2009-04-03  310  	/* key ends in a double NUL */
9ae326a69004de David Howells    2009-04-03  311  	key = key + nlen + 1;
9ae326a69004de David Howells    2009-04-03  312  	if (!*key)
9ae326a69004de David Howells    2009-04-03  313  		key = NULL;
9ae326a69004de David Howells    2009-04-03  314  
9ae326a69004de David Howells    2009-04-03  315  lookup_again:
9ae326a69004de David Howells    2009-04-03  316  	/* search the current directory for the element name */
9ae326a69004de David Howells    2009-04-03  317  	_debug("lookup '%s'", name);
9ae326a69004de David Howells    2009-04-03  318  
5955102c9984fa Al Viro          2016-01-22  319  	inode_lock_nested(d_inode(dir), I_MUTEX_PARENT);
9ae326a69004de David Howells    2009-04-03  320  
9ae326a69004de David Howells    2009-04-03  321  	start = jiffies;
9ae326a69004de David Howells    2009-04-03  322  	next = lookup_one_len(name, dir, nlen);
9ae326a69004de David Howells    2009-04-03  323  	cachefiles_hist(cachefiles_lookup_histogram, start);
a18feb55769b70 David Howells    2018-04-04  324  	if (IS_ERR(next)) {
a18feb55769b70 David Howells    2018-04-04  325  		trace_cachefiles_lookup(object, next, NULL);
db940cc2b33723 David Howells    2020-02-06  326  		ret = PTR_ERR(next);
                                                                ^^^^^^^^^^^^^^^^^^^
9ae326a69004de David Howells    2009-04-03  327  		goto lookup_error;
a18feb55769b70 David Howells    2018-04-04  328  	}
9ae326a69004de David Howells    2009-04-03  329  
a18feb55769b70 David Howells    2018-04-04  330  	inode = d_backing_inode(next);
a18feb55769b70 David Howells    2018-04-04  331  	trace_cachefiles_lookup(object, next, inode);

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