[security:landlock_lsm 8/12] security/landlock/syscall.c:216:13: warning: Uninitialized variable: ruleset

kernel test robot lkp at intel.com
Tue Nov 10 10:12:57 UTC 2020


tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git landlock_lsm
head:   96b3198c4025c11347651700b77e45a686d78553
commit: 0c901260bd29a3d6019531d3a3fdff7859aa88e1 [8/12] landlock: Add syscall implementations
compiler: powerpc64-linux-gcc (GCC) 9.3.0

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


"cppcheck warnings: (new ones prefixed by >>)"
>> security/landlock/syscall.c:216:13: warning: Uninitialized variable: ruleset [uninitvar]
    return err ? ERR_PTR(err) : ruleset;
               ^

vim +216 security/landlock/syscall.c

   189	
   190	/*
   191	 * Returns an owned ruleset from a FD. It is thus needed to call
   192	 * landlock_put_ruleset() on the return value.
   193	 */
   194	static struct landlock_ruleset *get_ruleset_from_fd(const int fd,
   195			const fmode_t mode)
   196	{
   197		struct fd ruleset_f;
   198		struct landlock_ruleset *ruleset;
   199		int err;
   200	
   201		ruleset_f = fdget(fd);
   202		if (!ruleset_f.file)
   203			return ERR_PTR(-EBADF);
   204	
   205		/* Checks FD type and access right. */
   206		err = 0;
   207		if (ruleset_f.file->f_op != &ruleset_fops)
   208			err = -EBADFD;
   209		else if (!(ruleset_f.file->f_mode & mode))
   210			err = -EPERM;
   211		if (!err) {
   212			ruleset = ruleset_f.file->private_data;
   213			landlock_get_ruleset(ruleset);
   214		}
   215		fdput(ruleset_f);
 > 216		return err ? ERR_PTR(err) : ruleset;
   217	}
   218	

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



More information about the Linux-security-module-archive mailing list