All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: drivers/block/loop.c:2121:38: warning: Although the value stored to 'xfer' is used in the enclosing expression, the value is never actually read from 'xfer' [clang-analyzer-deadcode.DeadStores]
Date: Tue, 31 Aug 2021 10:18:47 +0800	[thread overview]
Message-ID: <202108311022.ImQpm0VG-lkp@intel.com> (raw)

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

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
CC: 0day robot <lkp@intel.com>

tree:   https://github.com/0day-ci/linux/commits/UPDATE-20210829-092430/Tetsuo-Handa/loop-replace-loop_ctl_mutex-with-loop_idr_spinlock/20210827-000519
head:   d1d1d6b0374667ffe7418416765eedda70f0b6a5
commit: d1d1d6b0374667ffe7418416765eedda70f0b6a5 loop: reduce the loop_ctl_mutex scope
date:   2 days ago
:::::: branch date: 2 days ago
:::::: commit date: 2 days ago
config: x86_64-randconfig-c007-20210829 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 510e106fa8635e7f9c51c896180b971de6309b2f)
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
        # https://github.com/0day-ci/linux/commit/d1d1d6b0374667ffe7418416765eedda70f0b6a5
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review UPDATE-20210829-092430/Tetsuo-Handa/loop-replace-loop_ctl_mutex-with-loop_idr_spinlock/20210827-000519
        git checkout d1d1d6b0374667ffe7418416765eedda70f0b6a5
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 clang-analyzer 

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


clang-analyzer warnings: (new ones prefixed by >>)
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:306:2: note: expanded from macro '__compiletime_assert'
           do {                                                            \
           ^
   kernel/locking/rtmutex.c:298:30: note: Passing null pointer value via 1st parameter 'left'
           return rt_mutex_waiter_less(__node_2_pi_waiter(a), __node_2_pi_waiter(b));
                                       ^
   kernel/locking/rtmutex.c:293:2: note: expanded from macro '__node_2_pi_waiter'
           rb_entry((node), struct rt_mutex_waiter, pi_tree_entry)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/rbtree.h:38:37: note: expanded from macro 'rb_entry'
   #define rb_entry(ptr, type, member) container_of(ptr, type, member)
                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kernel.h:493:41: note: expanded from macro 'container_of'
   #define container_of(ptr, type, member) ({                              \
                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/locking/rtmutex.c:298:9: note: Calling 'rt_mutex_waiter_less'
           return rt_mutex_waiter_less(__node_2_pi_waiter(a), __node_2_pi_waiter(b));
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/locking/rtmutex.c:235:6: note: Access to field 'prio' results in a dereference of a null pointer (loaded from variable 'left')
           if (left->prio < right->prio)
               ^~~~
   kernel/locking/rtmutex.c:285:6: warning: Access to field '__rb_parent_color' results in a dereference of a null pointer [clang-analyzer-core.NullDereference]
           if (RB_EMPTY_NODE(&waiter->tree_entry))
               ^
   include/linux/rbtree.h:44:3: note: expanded from macro 'RB_EMPTY_NODE'
           ((node)->__rb_parent_color == (unsigned long)(node))
            ^
   kernel/locking/rtmutex.c:1764:6: note: Assuming the condition is true
           if (rt_mutex_owner(lock) != current) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/locking/rtmutex.c:1764:2: note: Taking true branch
           if (rt_mutex_owner(lock) != current) {
           ^
   kernel/locking/rtmutex.c:1765:23: note: Passing value via 2nd parameter 'waiter'
                   remove_waiter(lock, waiter);
                                       ^~~~~~
   kernel/locking/rtmutex.c:1765:3: note: Calling 'remove_waiter'
                   remove_waiter(lock, waiter);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/locking/rtmutex.c:1042:24: note: Assuming pointer value is null
           bool is_top_waiter = (waiter == rt_mutex_top_waiter(lock));
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/locking/rtmutex.c:1046:2: note: 'debug_locks' is 0
           lockdep_assert_held(&lock->wait_lock);
           ^
   include/linux/lockdep.h:310:11: note: expanded from macro 'lockdep_assert_held'
                   WARN_ON(debug_locks &&                                  \
                           ^~~~~~~~~~~
   include/asm-generic/bug.h:121:25: note: expanded from macro 'WARN_ON'
           int __ret_warn_on = !!(condition);                              \
                                  ^~~~~~~~~
   kernel/locking/rtmutex.c:1046:2: note: Left side of '&&' is false
           lockdep_assert_held(&lock->wait_lock);
           ^
   include/linux/lockdep.h:310:23: note: expanded from macro 'lockdep_assert_held'
                   WARN_ON(debug_locks &&                                  \
                                       ^
   kernel/locking/rtmutex.c:1046:2: note: Taking false branch
           lockdep_assert_held(&lock->wait_lock);
           ^
   include/linux/lockdep.h:310:3: note: expanded from macro 'lockdep_assert_held'
                   WARN_ON(debug_locks &&                                  \
                   ^
   include/asm-generic/bug.h:122:2: note: expanded from macro 'WARN_ON'
           if (unlikely(__ret_warn_on))                                    \
           ^
   kernel/locking/rtmutex.c:1046:2: note: Loop condition is false.  Exiting loop
           lockdep_assert_held(&lock->wait_lock);
           ^
   include/linux/lockdep.h:309:32: note: expanded from macro 'lockdep_assert_held'
   #define lockdep_assert_held(l)  do {                                    \
                                   ^
   kernel/locking/rtmutex.c:1049:25: note: Passing null pointer value via 2nd parameter 'waiter'
           rt_mutex_dequeue(lock, waiter);
                                  ^~~~~~
   kernel/locking/rtmutex.c:1049:2: note: Calling 'rt_mutex_dequeue'
           rt_mutex_dequeue(lock, waiter);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/locking/rtmutex.c:285:6: note: Access to field '__rb_parent_color' results in a dereference of a null pointer
           if (RB_EMPTY_NODE(&waiter->tree_entry))
               ^
   include/linux/rbtree.h:44:3: note: expanded from macro 'RB_EMPTY_NODE'
           ((node)->__rb_parent_color == (unsigned long)(node))
            ^~~~~~~~~~~~~~~~~~~~~~~~~
   Suppressed 3 warnings (2 in non-user code, 1 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   8 warnings generated.
   drivers/block/loop.c:1000:19: warning: Value stored to 'node' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
           struct rb_node **node = &(lo->worker_tree.rb_node), *parent = NULL;
                            ^~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/block/loop.c:1000:19: note: Value stored to 'node' during its initialization is never read
           struct rb_node **node = &(lo->worker_tree.rb_node), *parent = NULL;
                            ^~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/block/loop.c:2121:38: warning: Although the value stored to 'xfer' is used in the enclosing expression, the value is never actually read from 'xfer' [clang-analyzer-deadcode.DeadStores]
           if (n == 0 || n >= MAX_LO_CRYPT || (xfer = xfer_funcs[n]) == NULL)
                                               ^      ~~~~~~~~~~~~~
   drivers/block/loop.c:2121:38: note: Although the value stored to 'xfer' is used in the enclosing expression, the value is never actually read from 'xfer'
           if (n == 0 || n >= MAX_LO_CRYPT || (xfer = xfer_funcs[n]) == NULL)
                                               ^      ~~~~~~~~~~~~~
   drivers/block/loop.c:2332:2: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores]
           err = -ENOMEM;
           ^     ~~~~~~~
   drivers/block/loop.c:2332:2: note: Value stored to 'err' is never read
           err = -ENOMEM;
           ^     ~~~~~~~
>> drivers/block/loop.c:2469:3: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores]
                   ret = -EBUSY;
                   ^     ~~~~~~
   drivers/block/loop.c:2469:3: note: Value stored to 'ret' is never read
                   ret = -EBUSY;
                   ^     ~~~~~~
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   drivers/block/drbd/drbd_bitmap.c:654:3: warning: Value stored to 'owords' is never read [clang-analyzer-deadcode.DeadStores]
                   owords = b->bm_words;
                   ^        ~~~~~~~~~~~
   drivers/block/drbd/drbd_bitmap.c:654:3: note: Value stored to 'owords' is never read
                   owords = b->bm_words;
                   ^        ~~~~~~~~~~~
   drivers/block/drbd/drbd_bitmap.c:1156:6: warning: Use of memory after it is freed [clang-analyzer-unix.Malloc]
           if (ctx->error) {
               ^
   drivers/block/drbd/drbd_bitmap.c:1244:9: note: Calling 'bm_rw'
           return bm_rw(device, BM_AIO_WRITE_HINTED | BM_AIO_COPY_PAGES, 0);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/block/drbd/drbd_bitmap.c:1050:6: note: Assuming 'ctx' is non-null
           if (!ctx)
               ^~~~
   drivers/block/drbd/drbd_bitmap.c:1050:2: note: Taking false branch
           if (!ctx)
           ^
   drivers/block/drbd/drbd_bitmap.c:1063:7: note: '?' condition is true
           if (!get_ldev_if_state(device, D_ATTACHING)) {  /* put is in drbd_bm_aio_ctx_destroy() */
                ^
   drivers/block/drbd/drbd_int.h:2083:3: note: expanded from macro 'get_ldev_if_state'
           (_get_ldev_if_state((_device), (_min_state)) ?                  \
            ^
   drivers/block/drbd/drbd_bitmap.c:1063:2: note: Taking false branch
           if (!get_ldev_if_state(device, D_ATTACHING)) {  /* put is in drbd_bm_aio_ctx_destroy() */
           ^
   drivers/block/drbd/drbd_bitmap.c:1071:2: note: Taking false branch
           if (0 == (ctx->flags & ~BM_AIO_READ))
           ^
   drivers/block/drbd/drbd_bitmap.c:1084:2: note: Taking false branch
           if (flags & BM_AIO_READ) {
           ^
   drivers/block/drbd/drbd_bitmap.c:1091:9: note: Taking true branch
           } else if (flags & BM_AIO_WRITE_HINTED) {
                  ^
   drivers/block/drbd/drbd_bitmap.c:1094:18: note: Assuming 'hint' is >= field 'n_bitmap_hints'
                   for (hint = 0; hint < b->n_bitmap_hints; hint++) {
                                  ^~~~~~~~~~~~~~~~~~~~~~~~
   drivers/block/drbd/drbd_bitmap.c:1094:3: note: Loop condition is false. Execution continues on line 1141
                   for (hint = 0; hint < b->n_bitmap_hints; hint++) {
                   ^
   drivers/block/drbd/drbd_bitmap.c:1141:6: note: Assuming the condition is false
           if (!atomic_dec_and_test(&ctx->in_flight))
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/block/drbd/drbd_bitmap.c:1141:2: note: Taking false branch
           if (!atomic_dec_and_test(&ctx->in_flight))
           ^
   drivers/block/drbd/drbd_bitmap.c:1144:3: note: Calling 'kref_put'
                   kref_put(&ctx->kref, &drbd_bm_aio_ctx_destroy);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kref.h:64:2: note: Taking true branch
           if (refcount_dec_and_test(&kref->refcount)) {
           ^
   include/linux/kref.h:65:3: note: Calling 'drbd_bm_aio_ctx_destroy'
                   release(kref);
                   ^~~~~~~~~~~~~
   drivers/block/drbd/drbd_bitmap.c:926:32: note: Left side of '&&' is false
           struct drbd_bm_aio_ctx *ctx = container_of(kref, struct drbd_bm_aio_ctx, kref);
                                         ^
   include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
                                                                      ^
   drivers/block/drbd/drbd_bitmap.c:926:32: note: Taking false branch
           struct drbd_bm_aio_ctx *ctx = container_of(kref, struct drbd_bm_aio_ctx, kref);
                                         ^
   include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:308:3: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                   ^
   drivers/block/drbd/drbd_bitmap.c:926:32: note: Loop condition is false.  Exiting loop
           struct drbd_bm_aio_ctx *ctx = container_of(kref, struct drbd_bm_aio_ctx, kref);
                                         ^
   include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)

vim +2121 drivers/block/loop.c

^1da177e4c3f41 Linus Torvalds 2005-04-16  2115  
^1da177e4c3f41 Linus Torvalds 2005-04-16  2116  int loop_unregister_transfer(int number)
^1da177e4c3f41 Linus Torvalds 2005-04-16  2117  {
^1da177e4c3f41 Linus Torvalds 2005-04-16  2118  	unsigned int n = number;
^1da177e4c3f41 Linus Torvalds 2005-04-16  2119  	struct loop_func_table *xfer;
^1da177e4c3f41 Linus Torvalds 2005-04-16  2120  
^1da177e4c3f41 Linus Torvalds 2005-04-16 @2121  	if (n == 0 || n >= MAX_LO_CRYPT || (xfer = xfer_funcs[n]) == NULL)
^1da177e4c3f41 Linus Torvalds 2005-04-16  2122  		return -EINVAL;
d1d1d6b0374667 Tetsuo Handa   2021-08-29  2123  	/*
d1d1d6b0374667 Tetsuo Handa   2021-08-29  2124  	 * This function is called from only cleanup_cryptoloop().
d1d1d6b0374667 Tetsuo Handa   2021-08-29  2125  	 * Given that each loop device that has a transfer enabled holds a
d1d1d6b0374667 Tetsuo Handa   2021-08-29  2126  	 * reference to the module implementing it we should never get here
d1d1d6b0374667 Tetsuo Handa   2021-08-29  2127  	 * with a transfer that is set (unless forced module unloading is
d1d1d6b0374667 Tetsuo Handa   2021-08-29  2128  	 * requested). Thus, check module's refcount and warn if this is
d1d1d6b0374667 Tetsuo Handa   2021-08-29  2129  	 * not a clean unloading.
d1d1d6b0374667 Tetsuo Handa   2021-08-29  2130  	 */
d1d1d6b0374667 Tetsuo Handa   2021-08-29  2131  #ifdef CONFIG_MODULE_UNLOAD
d1d1d6b0374667 Tetsuo Handa   2021-08-29  2132  	if (xfer->owner && module_refcount(xfer->owner) != -1)
d1d1d6b0374667 Tetsuo Handa   2021-08-29  2133  		pr_err("Unregistering a transfer function in use. Expect kernel crashes.\n");
d1d1d6b0374667 Tetsuo Handa   2021-08-29  2134  #endif
^1da177e4c3f41 Linus Torvalds 2005-04-16  2135  
^1da177e4c3f41 Linus Torvalds 2005-04-16  2136  	xfer_funcs[n] = NULL;
^1da177e4c3f41 Linus Torvalds 2005-04-16  2137  	return 0;
^1da177e4c3f41 Linus Torvalds 2005-04-16  2138  }
^1da177e4c3f41 Linus Torvalds 2005-04-16  2139  

---
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: 41080 bytes --]

                 reply	other threads:[~2021-08-31  2:18 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=202108311022.ImQpm0VG-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=kbuild@lists.01.org \
    /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 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.