Skip to contentSkip to conversation

drivers/ufs/core/ufs-mcq.c:293 ufshcd_mcq_poll_cqe_nolock() error: we previously assumed 'compl_cmd' could be null (see line 292)

PATCH New Dan Carpenter 1 participant 1 message Jul 2, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 3/4 drivers/ufs/core/ufs-mcq.c:293 ufshcd_mcq_poll_cqe_nolock() error: we previously assumed 'compl_cmd' could be null (see line 292)

tree:   https://android.googlesource.com/kernel/common android14-5.15
head:   2447b4c0a5ca8efd6579d4a168103269dfac1866
commit: 8563ce58954679187f0c269a504520d8def37e41 [3/4] BACKPORT: FROMLIST: scsi: ufs: Make the polling code report which command has been completed
config: i386-randconfig-141-20240702 (https://download.01.org/0day-ci/archive/20240703/[email protected]/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)

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 <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

smatch warnings:
drivers/ufs/core/ufs-mcq.c:293 ufshcd_mcq_poll_cqe_nolock() error: we previously assumed 'compl_cmd' could be null (see line 292)

vim +/compl_cmd +293 drivers/ufs/core/ufs-mcq.c

31fe4a16211a23 Asutosh Das     2023-01-13  283  unsigned long ufshcd_mcq_poll_cqe_nolock(struct ufs_hba *hba,
8563ce58954679 Bart Van Assche 2024-04-11  284  					 struct ufs_hw_queue *hwq,
8563ce58954679 Bart Van Assche 2024-04-11  285  					 struct scsi_cmnd **compl_cmd)
31fe4a16211a23 Asutosh Das     2023-01-13  286  {
31fe4a16211a23 Asutosh Das     2023-01-13  287  	unsigned long completed_reqs = 0;
31fe4a16211a23 Asutosh Das     2023-01-13  288  
31fe4a16211a23 Asutosh Das     2023-01-13  289  	ufshcd_mcq_update_cq_tail_slot(hwq);
31fe4a16211a23 Asutosh Das     2023-01-13  290  	while (!ufshcd_mcq_is_cq_empty(hwq)) {
8563ce58954679 Bart Van Assche 2024-04-11  291  		if (ufshcd_mcq_process_cqe(hba, hwq,
8563ce58954679 Bart Van Assche 2024-04-11 @292  					   compl_cmd ? *compl_cmd : NULL))
                                                                                           ^^^^^^^^^

This line assumes assumes compl_cmd can be NULL

8563ce58954679 Bart Van Assche 2024-04-11 @293  			*compl_cmd = NULL;
                                                                        ^^^^^^^^^^

Unchecked derereference. Although it could be false positive if ufshcd_mcq_process_cqe() only returns true for non-NULL.

31fe4a16211a23 Asutosh Das     2023-01-13  294  		ufshcd_mcq_inc_cq_head_slot(hwq);
31fe4a16211a23 Asutosh Das     2023-01-13  295  		completed_reqs++;
31fe4a16211a23 Asutosh Das     2023-01-13  296  	}
31fe4a16211a23 Asutosh Das     2023-01-13  297  
31fe4a16211a23 Asutosh Das     2023-01-13  298  	if (completed_reqs)
31fe4a16211a23 Asutosh Das     2023-01-13  299  		ufshcd_mcq_update_cq_head(hwq);
31fe4a16211a23 Asutosh Das     2023-01-13  300  
31fe4a16211a23 Asutosh Das     2023-01-13  301  	return completed_reqs;
31fe4a16211a23 Asutosh Das     2023-01-13  302  }
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki