:::::: :::::: Manual check reason: "low confidence static check warning: block/blk-lib.c:134:3: warning: Dereference of null pointer [clang-analyzer-core.NullDereference]" :::::: BCC: lkp@intel.com CC: llvm@lists.linux.dev CC: oe-kbuild-all@lists.linux.dev In-Reply-To: <20221123055827.26996-3-nj.shetty@samsung.com> References: <20221123055827.26996-3-nj.shetty@samsung.com> TO: Nitesh Shetty TO: axboe@kernel.dk TO: agk@redhat.com TO: snitzer@kernel.org TO: dm-devel@redhat.com TO: kbusch@kernel.org TO: hch@lst.de TO: sagi@grimberg.me TO: james.smart@broadcom.com TO: kch@nvidia.com TO: damien.lemoal@opensource.wdc.com TO: naohiro.aota@wdc.com TO: jth@kernel.org TO: viro@zeniv.linux.org.uk CC: linux-block@vger.kernel.org CC: linux-kernel@vger.kernel.org CC: linux-nvme@lists.infradead.org CC: linux-fsdevel@vger.kernel.org CC: anuj20.g@samsung.com CC: joshi.k@samsung.com CC: p.raghav@samsung.com CC: nitheshshetty@gmail.com CC: gost.dev@samsung.com CC: Nitesh Shetty Hi Nitesh, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on axboe-block/for-next] [also build test WARNING on next-20221202] [cannot apply to device-mapper-dm/for-next linus/master v6.1-rc7] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Nitesh-Shetty/block-Introduce-queue-limits-for-copy-offload-support/20221123-145837 base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next patch link: https://lore.kernel.org/r/20221123055827.26996-3-nj.shetty%40samsung.com patch subject: [PATCH v5 02/10] block: Add copy offload support infrastructure :::::: branch date: 9 days ago :::::: commit date: 9 days ago config: s390-randconfig-c005-20221128 compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 6e4cea55f0d1104408b26ac574566a0e4de48036) 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 s390 cross compiling tool for clang build # apt-get install binutils-s390x-linux-gnu # https://github.com/intel-lab-lkp/linux/commit/101fd213e34571287d11546f15a89f06ae9b9746 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Nitesh-Shetty/block-Introduce-queue-limits-for-copy-offload-support/20221123-145837 git checkout 101fd213e34571287d11546f15a89f06ae9b9746 # save the config file COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=s390 clang-analyzer If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot clang_analyzer warnings: (new ones prefixed by >>) ^ include/linux/rcupdate.h:638:31: note: expanded from macro 'rcu_dereference_protected' __rcu_dereference_protected((p), __UNIQUE_ID(rcu), (c), __rcu) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/rcupdate.h:436:35: note: expanded from macro '__rcu_dereference_protected' ((typeof(*p) __force __kernel *)(p)); \ ^ block/blk-ioc.c:302:27: warning: Dereference of null pointer [clang-analyzer-core.NullDereference] struct io_context *ioc = current->io_context; ^ arch/s390/include/asm/current.h:17:45: note: expanded from macro 'current' #define current ((struct task_struct *const)S390_lowcore.current_task) ^~~~~~~~~~~~~~~~~~~~~~~~~ arch/s390/include/asm/lowcore.h:215:22: note: expanded from macro 'S390_lowcore' #define S390_lowcore (*((struct lowcore *) 0)) ^ block/blk-ioc.c:302:27: note: Dereference of null pointer struct io_context *ioc = current->io_context; ^ arch/s390/include/asm/current.h:17:45: note: expanded from macro 'current' #define current ((struct task_struct *const)S390_lowcore.current_task) ^~~~~~~~~~~~~~~~~~~~~~~~~ arch/s390/include/asm/lowcore.h:215:22: note: expanded from macro 'S390_lowcore' #define S390_lowcore (*((struct lowcore *) 0)) ^ Suppressed 22 warnings (10 in non-user code, 12 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. 11 warnings generated. Suppressed 11 warnings (11 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. 26 warnings generated. arch/s390/include/asm/spinlock.h:61:52: warning: Dereference of null pointer [clang-analyzer-core.NullDereference] return likely(__atomic_cmpxchg_bool(&lp->lock, 0, SPINLOCK_LOCKVAL)); ^ arch/s390/include/asm/spinlock.h:19:26: note: expanded from macro 'SPINLOCK_LOCKVAL' #define SPINLOCK_LOCKVAL (S390_lowcore.spinlock_lockval) ^ block/blk-lib.c:245:2: note: Calling '__raw_spin_lock_irqsave' spin_lock_irqsave(&cio->list_lock, flags); ^ include/linux/spinlock.h:380:2: note: expanded from macro 'spin_lock_irqsave' raw_spin_lock_irqsave(spinlock_check(lock), flags); \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/spinlock.h:243:11: note: expanded from macro 'raw_spin_lock_irqsave' flags = _raw_spin_lock_irqsave(lock); \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/spinlock_api_smp.h:59:38: note: expanded from macro '_raw_spin_lock_irqsave' #define _raw_spin_lock_irqsave(lock) __raw_spin_lock_irqsave(lock) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/spinlock_api_smp.h:108:2: note: Loop condition is false. Exiting loop local_irq_save(flags); ^ include/linux/irqflags.h:244:36: note: expanded from macro 'local_irq_save' #define local_irq_save(flags) do { raw_local_irq_save(flags); } while (0) ^ include/linux/irqflags.h:176:2: note: expanded from macro 'raw_local_irq_save' do { \ ^ include/linux/spinlock_api_smp.h:108:2: note: Loop condition is false. Exiting loop local_irq_save(flags); ^ include/linux/irqflags.h:244:31: note: expanded from macro 'local_irq_save' #define local_irq_save(flags) do { raw_local_irq_save(flags); } while (0) ^ include/linux/spinlock_api_smp.h:110:2: note: Loop condition is false. Exiting loop spin_acquire(&lock->dep_map, 0, 0, _RET_IP_); ^ include/linux/lockdep.h:526:35: note: expanded from macro 'spin_acquire' #define spin_acquire(l, s, t, i) lock_acquire_exclusive(l, s, t, NULL, i) ^ include/linux/lockdep.h:522:48: note: expanded from macro 'lock_acquire_exclusive' #define lock_acquire_exclusive(l, s, t, n, i) lock_acquire(l, s, t, 0, 1, n, i) ^ include/linux/lockdep.h:360:44: note: expanded from macro 'lock_acquire' # define lock_acquire(l, s, t, r, c, n, i) do { } while (0) ^ include/linux/spinlock_api_smp.h:111:44: note: Calling 'do_raw_spin_lock' LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock); ^ include/linux/lockdep.h:481:2: note: expanded from macro 'LOCK_CONTENDED' lock(_lock) ^~~~~~~~~~~ include/linux/spinlock.h:186:2: note: Calling 'arch_spin_lock' arch_spin_lock(&lock->raw_lock); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/s390/include/asm/spinlock.h:66:7: note: Calling 'arch_spin_trylock_once' if (!arch_spin_trylock_once(lp)) ^~~~~~~~~~~~~~~~~~~~~~~~~~ arch/s390/include/asm/spinlock.h:61:52: note: Dereference of null pointer return likely(__atomic_cmpxchg_bool(&lp->lock, 0, SPINLOCK_LOCKVAL)); ^ arch/s390/include/asm/spinlock.h:19:26: note: expanded from macro 'SPINLOCK_LOCKVAL' #define SPINLOCK_LOCKVAL (S390_lowcore.spinlock_lockval) ^ include/linux/compiler.h:45:39: note: expanded from macro 'likely' # define likely(x) (__branch_check__(x, 1, __builtin_constant_p(x))) ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/compiler.h:33:34: note: expanded from macro '__branch_check__' ______r = __builtin_expect(!!(x), expect); \ ^ >> block/blk-lib.c:134:3: warning: Dereference of null pointer [clang-analyzer-core.NullDereference] __set_current_state(TASK_UNINTERRUPTIBLE); ^ include/linux/sched.h:214:14: note: expanded from macro '__set_current_state' WRITE_ONCE(current->__state, (state_value)); \ ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/s390/include/asm/current.h:17:45: note: expanded from macro 'current' #define current ((struct task_struct *const)S390_lowcore.current_task) ^ arch/s390/include/asm/lowcore.h:215:22: note: expanded from macro 'S390_lowcore' #define S390_lowcore (*((struct lowcore *) 0)) ^ include/asm-generic/rwonce.h:61:15: note: expanded from macro 'WRITE_ONCE' __WRITE_ONCE(x, val); \ ~~~~~~~~~~~~~^~~~~~~ include/asm-generic/rwonce.h:55:27: note: expanded from macro '__WRITE_ONCE' *(volatile typeof(x) *)&(x) = (val); \ ^ block/blk-lib.c:130:6: note: Assuming field 'endio' is null if (cio->endio) ^~~~~~~~~~ block/blk-lib.c:130:2: note: Taking false branch if (cio->endio) ^ block/blk-lib.c:133:6: note: Assuming the condition is true if (atomic_read(&cio->refcount)) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~ block/blk-lib.c:133:2: note: Taking true branch if (atomic_read(&cio->refcount)) { ^ block/blk-lib.c:134:3: note: Loop condition is false. Exiting loop __set_current_state(TASK_UNINTERRUPTIBLE); ^ include/linux/sched.h:213:3: note: expanded from macro '__set_current_state' debug_normal_state_change((state_value)); \ ^ include/linux/sched.h:168:42: note: expanded from macro 'debug_normal_state_change' # define debug_normal_state_change(cond) do { } while (0) ^ block/blk-lib.c:134:3: note: Left side of '||' is false __set_current_state(TASK_UNINTERRUPTIBLE); ^ include/linux/sched.h:214:3: note: expanded from macro '__set_current_state' WRITE_ONCE(current->__state, (state_value)); \ ^ include/asm-generic/rwonce.h:60:2: note: expanded from macro 'WRITE_ONCE' compiletime_assert_rwonce_type(x); \ ^ include/asm-generic/rwonce.h:36:21: note: expanded from macro 'compiletime_assert_rwonce_type' compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \ ^ include/linux/compiler_types.h:324:3: note: expanded from macro '__native_word' (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \ ^ block/blk-lib.c:134:3: note: Left side of '||' is false __set_current_state(TASK_UNINTERRUPTIBLE); ^ include/linux/sched.h:214:3: note: expanded from macro '__set_current_state' WRITE_ONCE(current->__state, (state_value)); \ ^ include/asm-generic/rwonce.h:60:2: note: expanded from macro 'WRITE_ONCE' compiletime_assert_rwonce_type(x); \ ^ include/asm-generic/rwonce.h:36:21: note: expanded from macro 'compiletime_assert_rwonce_type' compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \ ^ include/linux/compiler_types.h:324:3: note: expanded from macro '__native_word' (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \ ^ block/blk-lib.c:134:3: note: Left side of '||' is true __set_current_state(TASK_UNINTERRUPTIBLE); ^ include/linux/sched.h:214:3: note: expanded from macro '__set_current_state' WRITE_ONCE(current->__state, (state_value)); \ ^ include/asm-generic/rwonce.h:60:2: note: expanded from macro 'WRITE_ONCE' compiletime_assert_rwonce_type(x); \ ^ include/asm-generic/rwonce.h:36:21: note: expanded from macro 'compiletime_assert_rwonce_type' compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \ ^ include/linux/compiler_types.h:325:28: note: expanded from macro '__native_word' sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long)) ^ block/blk-lib.c:134:3: note: Taking false branch __set_current_state(TASK_UNINTERRUPTIBLE); ^ include/linux/sched.h:214:3: note: expanded from macro '__set_current_state' WRITE_ONCE(current->__state, (state_value)); \ ^ include/asm-generic/rwonce.h:60:2: note: expanded from macro 'WRITE_ONCE' compiletime_assert_rwonce_type(x); \ ^ include/asm-generic/rwonce.h:36:2: note: expanded from macro 'compiletime_assert_rwonce_type' compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long), \ ^ include/linux/compiler_types.h:357:2: note: expanded from macro 'compiletime_assert' _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) ^ include/linux/compiler_types.h:345:2: note: expanded from macro '_compiletime_assert' __compiletime_assert(condition, msg, prefix, suffix) vim +134 block/blk-lib.c 3f14d792f9a8fe Dmitry Monakhov 2010-04-28 117 101fd213e34571 Nitesh Shetty 2022-11-23 118 /* 101fd213e34571 Nitesh Shetty 2022-11-23 119 * For synchronous copy offload/emulation, wait and process all in-flight BIOs. 101fd213e34571 Nitesh Shetty 2022-11-23 120 * This must only be called once all bios have been issued so that the refcount 101fd213e34571 Nitesh Shetty 2022-11-23 121 * can only decrease. This just waits for all bios to make it through 101fd213e34571 Nitesh Shetty 2022-11-23 122 * bio_copy_*_write_end_io. IO errors are propagated through cio->io_error. 101fd213e34571 Nitesh Shetty 2022-11-23 123 */ 101fd213e34571 Nitesh Shetty 2022-11-23 124 static int cio_await_completion(struct cio *cio) 101fd213e34571 Nitesh Shetty 2022-11-23 125 { 101fd213e34571 Nitesh Shetty 2022-11-23 126 int ret = 0; 101fd213e34571 Nitesh Shetty 2022-11-23 127 101fd213e34571 Nitesh Shetty 2022-11-23 128 atomic_dec(&cio->refcount); 101fd213e34571 Nitesh Shetty 2022-11-23 129 101fd213e34571 Nitesh Shetty 2022-11-23 130 if (cio->endio) 101fd213e34571 Nitesh Shetty 2022-11-23 131 return 0; 101fd213e34571 Nitesh Shetty 2022-11-23 132 101fd213e34571 Nitesh Shetty 2022-11-23 133 if (atomic_read(&cio->refcount)) { 101fd213e34571 Nitesh Shetty 2022-11-23 @134 __set_current_state(TASK_UNINTERRUPTIBLE); 101fd213e34571 Nitesh Shetty 2022-11-23 135 blk_io_schedule(); 101fd213e34571 Nitesh Shetty 2022-11-23 136 } 101fd213e34571 Nitesh Shetty 2022-11-23 137 101fd213e34571 Nitesh Shetty 2022-11-23 138 ret = cio->io_err; 101fd213e34571 Nitesh Shetty 2022-11-23 139 kfree(cio); 101fd213e34571 Nitesh Shetty 2022-11-23 140 101fd213e34571 Nitesh Shetty 2022-11-23 141 return ret; 101fd213e34571 Nitesh Shetty 2022-11-23 142 } 101fd213e34571 Nitesh Shetty 2022-11-23 143 -- 0-DAY CI Kernel Test Service https://01.org/lkp