Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev
Subject: [axboe-block:io_uring-rsrc 10/12] io_uring/rsrc.c:207:31: warning: variable 'i' is uninitialized when used here
Date: Mon, 28 Oct 2024 02:52:15 +0800	[thread overview]
Message-ID: <202410280250.jqKtTrSR-lkp@intel.com> (raw)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git io_uring-rsrc
head:   6aea948dd2af540e0c9ffd392131e68be59de434
commit: 78bb8a4ca9328c808a7b33955fbaad8e139c2a4a [10/12] io_uring/rsrc: use io_rsrc_node_lookup() consistently
config: x86_64-allnoconfig (https://download.01.org/0day-ci/archive/20241028/202410280250.jqKtTrSR-lkp@intel.com/config)
compiler: clang version 19.1.2 (https://github.com/llvm/llvm-project 7ba7d8e2f7b6445b60679da826210cdde29eaf8b)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241028/202410280250.jqKtTrSR-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/202410280250.jqKtTrSR-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from io_uring/rsrc.c:6:
   In file included from include/linux/mm.h:2213:
   include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
>> io_uring/rsrc.c:207:31: warning: variable 'i' is uninitialized when used here [-Wuninitialized]
     207 |                         ctx->file_table.data.nodes[i] = NULL;
         |                                                    ^
   io_uring/rsrc.c:180:11: note: initialize the variable 'i' to silence this warning
     180 |         int fd, i, err = 0;
         |                  ^
         |                   = 0
   2 warnings generated.


vim +/i +207 io_uring/rsrc.c

73572984481907d Jens Axboe        2022-06-13  173  
73572984481907d Jens Axboe        2022-06-13  174  static int __io_sqe_files_update(struct io_ring_ctx *ctx,
73572984481907d Jens Axboe        2022-06-13  175  				 struct io_uring_rsrc_update2 *up,
73572984481907d Jens Axboe        2022-06-13  176  				 unsigned nr_args)
73572984481907d Jens Axboe        2022-06-13  177  {
73572984481907d Jens Axboe        2022-06-13  178  	u64 __user *tags = u64_to_user_ptr(up->tags);
73572984481907d Jens Axboe        2022-06-13  179  	__s32 __user *fds = u64_to_user_ptr(up->data);
73572984481907d Jens Axboe        2022-06-13  180  	int fd, i, err = 0;
73572984481907d Jens Axboe        2022-06-13  181  	unsigned int done;
73572984481907d Jens Axboe        2022-06-13  182  
195a2148900cc0b Jens Axboe        2024-10-26  183  	if (!ctx->file_table.data.nr)
73572984481907d Jens Axboe        2022-06-13  184  		return -ENXIO;
195a2148900cc0b Jens Axboe        2024-10-26  185  	if (up->offset + nr_args > ctx->file_table.data.nr)
73572984481907d Jens Axboe        2022-06-13  186  		return -EINVAL;
73572984481907d Jens Axboe        2022-06-13  187  
73572984481907d Jens Axboe        2022-06-13  188  	for (done = 0; done < nr_args; done++) {
78bb8a4ca9328c8 Jens Axboe        2024-10-27  189  		struct io_rsrc_node *node;
73572984481907d Jens Axboe        2022-06-13  190  		u64 tag = 0;
73572984481907d Jens Axboe        2022-06-13  191  
73572984481907d Jens Axboe        2022-06-13  192  		if ((tags && copy_from_user(&tag, &tags[done], sizeof(tag))) ||
73572984481907d Jens Axboe        2022-06-13  193  		    copy_from_user(&fd, &fds[done], sizeof(fd))) {
73572984481907d Jens Axboe        2022-06-13  194  			err = -EFAULT;
73572984481907d Jens Axboe        2022-06-13  195  			break;
73572984481907d Jens Axboe        2022-06-13  196  		}
73572984481907d Jens Axboe        2022-06-13  197  		if ((fd == IORING_REGISTER_FILES_SKIP || fd == -1) && tag) {
73572984481907d Jens Axboe        2022-06-13  198  			err = -EINVAL;
73572984481907d Jens Axboe        2022-06-13  199  			break;
73572984481907d Jens Axboe        2022-06-13  200  		}
73572984481907d Jens Axboe        2022-06-13  201  		if (fd == IORING_REGISTER_FILES_SKIP)
73572984481907d Jens Axboe        2022-06-13  202  			continue;
73572984481907d Jens Axboe        2022-06-13  203  
78bb8a4ca9328c8 Jens Axboe        2024-10-27  204  		node = io_rsrc_node_lookup(&ctx->file_table.data, up->offset + done);
78bb8a4ca9328c8 Jens Axboe        2024-10-27  205  		if (node) {
78bb8a4ca9328c8 Jens Axboe        2024-10-27  206  			io_put_rsrc_node(node);
195a2148900cc0b Jens Axboe        2024-10-26 @207  			ctx->file_table.data.nodes[i] = NULL;
73572984481907d Jens Axboe        2022-06-13  208  			io_file_bitmap_clear(&ctx->file_table, i);
73572984481907d Jens Axboe        2022-06-13  209  		}
73572984481907d Jens Axboe        2022-06-13  210  		if (fd != -1) {
4bfb0c9af832a18 Christoph Hellwig 2023-06-20  211  			struct file *file = fget(fd);
fdc1774df944e63 Jens Axboe        2024-10-25  212  			struct io_rsrc_node *node;
4bfb0c9af832a18 Christoph Hellwig 2023-06-20  213  
73572984481907d Jens Axboe        2022-06-13  214  			if (!file) {
73572984481907d Jens Axboe        2022-06-13  215  				err = -EBADF;
73572984481907d Jens Axboe        2022-06-13  216  				break;
73572984481907d Jens Axboe        2022-06-13  217  			}
73572984481907d Jens Axboe        2022-06-13  218  			/*
6e5e6d274956305 Jens Axboe        2023-12-19  219  			 * Don't allow io_uring instances to be registered.
73572984481907d Jens Axboe        2022-06-13  220  			 */
73572984481907d Jens Axboe        2022-06-13  221  			if (io_is_uring_fops(file)) {
73572984481907d Jens Axboe        2022-06-13  222  				fput(file);
73572984481907d Jens Axboe        2022-06-13  223  				err = -EBADF;
73572984481907d Jens Axboe        2022-06-13  224  				break;
73572984481907d Jens Axboe        2022-06-13  225  			}
195a2148900cc0b Jens Axboe        2024-10-26  226  			node = io_rsrc_node_alloc(ctx, &ctx->file_table.data, i,
195a2148900cc0b Jens Axboe        2024-10-26  227  						  IORING_RSRC_FILE);
fdc1774df944e63 Jens Axboe        2024-10-25  228  			if (!node) {
fdc1774df944e63 Jens Axboe        2024-10-25  229  				err = -ENOMEM;
fdc1774df944e63 Jens Axboe        2024-10-25  230  				fput(file);
fdc1774df944e63 Jens Axboe        2024-10-25  231  				break;
fdc1774df944e63 Jens Axboe        2024-10-25  232  			}
195a2148900cc0b Jens Axboe        2024-10-26  233  			ctx->file_table.data.nodes[i] = node;
f329b544bf9dada Jens Axboe        2024-10-26  234  			if (tag)
fdc1774df944e63 Jens Axboe        2024-10-25  235  				node->tag = tag;
fdc1774df944e63 Jens Axboe        2024-10-25  236  			io_fixed_file_set(node, file);
73572984481907d Jens Axboe        2022-06-13  237  			io_file_bitmap_set(&ctx->file_table, i);
73572984481907d Jens Axboe        2022-06-13  238  		}
73572984481907d Jens Axboe        2022-06-13  239  	}
73572984481907d Jens Axboe        2022-06-13  240  	return done ? done : err;
73572984481907d Jens Axboe        2022-06-13  241  }
73572984481907d Jens Axboe        2022-06-13  242  

:::::: The code at line 207 was first introduced by commit
:::::: 195a2148900cc0be03bc1ca8c3c67ad48127cf10 io_uring/rsrc: unify file and buffer resource tables

:::::: TO: Jens Axboe <axboe@kernel.dk>
:::::: CC: Jens Axboe <axboe@kernel.dk>

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

                 reply	other threads:[~2024-10-27 18:52 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=202410280250.jqKtTrSR-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=axboe@kernel.dk \
    --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