Hi Douglas, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on jejb-scsi/for-next] [also build test WARNING on mkp-scsi/for-next v5.18-rc1 next-20220407] [cannot apply to hch-configfs/for-next] [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] url: https://github.com/intel-lab-lkp/linux/commits/Douglas-Gilbert/scsi-fix-scsi_cmd-cmd_len/20220408-121036 base: https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next config: hexagon-randconfig-r041-20220408 (https://download.01.org/0day-ci/archive/20220408/202204081548.EhdacQg9-lkp@xxxxxxxxx/config) compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project c29a51b3a257908aebc01cd7c4655665db317d66) 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/intel-lab-lkp/linux/commit/efdf7335424993375502b298131c1d106fc5e6d4 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Douglas-Gilbert/scsi-fix-scsi_cmd-cmd_len/20220408-121036 git checkout efdf7335424993375502b298131c1d106fc5e6d4 # save the config file to linux build tree mkdir build_dir COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/scsi/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@xxxxxxxxx> All warnings (new ones prefixed by >>): >> drivers/scsi/scsi_ioctl.c:444:28: warning: result of comparison of constant 260 with expression of type 'unsigned char' is always false [-Wtautological-constant-out-of-range-compare] if (unlikely(hdr->cmd_len > SCSI_MAX_RUN_TIME_CDB_LEN)) { ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/compiler.h:48:41: note: expanded from macro 'unlikely' # define unlikely(x) (__branch_check__(x, 0, __builtin_constant_p(x))) ^ include/linux/compiler.h:33:34: note: expanded from macro '__branch_check__' ______r = __builtin_expect(!!(x), expect); \ ^ >> drivers/scsi/scsi_ioctl.c:444:28: warning: result of comparison of constant 260 with expression of type 'unsigned char' is always false [-Wtautological-constant-out-of-range-compare] if (unlikely(hdr->cmd_len > SCSI_MAX_RUN_TIME_CDB_LEN)) { ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/compiler.h:48:68: note: expanded from macro 'unlikely' # define unlikely(x) (__branch_check__(x, 0, __builtin_constant_p(x))) ^ include/linux/compiler.h:35:19: note: expanded from macro '__branch_check__' expect, is_constant); \ ^~~~~~~~~~~ 2 warnings generated. vim +444 drivers/scsi/scsi_ioctl.c 407 408 static int sg_io(struct scsi_device *sdev, struct sg_io_hdr *hdr, fmode_t mode) 409 { 410 unsigned long start_time; 411 ssize_t ret = 0; 412 int writing = 0; 413 int at_head = 0; 414 struct request *rq; 415 struct scsi_cmnd *scmd; 416 struct bio *bio; 417 418 if (hdr->interface_id != 'S') 419 return -EINVAL; 420 421 if (hdr->dxfer_len > (queue_max_hw_sectors(sdev->request_queue) << 9)) 422 return -EIO; 423 424 if (hdr->dxfer_len) 425 switch (hdr->dxfer_direction) { 426 default: 427 return -EINVAL; 428 case SG_DXFER_TO_DEV: 429 writing = 1; 430 break; 431 case SG_DXFER_TO_FROM_DEV: 432 case SG_DXFER_FROM_DEV: 433 break; 434 } 435 if (hdr->flags & SG_FLAG_Q_AT_HEAD) 436 at_head = 1; 437 438 rq = scsi_alloc_request(sdev->request_queue, writing ? 439 REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0); 440 if (IS_ERR(rq)) 441 return PTR_ERR(rq); 442 scmd = blk_mq_rq_to_pdu(rq); 443 > 444 if (unlikely(hdr->cmd_len > SCSI_MAX_RUN_TIME_CDB_LEN)) { 445 ret = -EINVAL; 446 goto out_put_request; 447 } 448 449 ret = scsi_fill_sghdr_rq(sdev, rq, hdr, mode); 450 if (ret < 0) 451 goto out_put_request; 452 453 ret = 0; 454 if (hdr->iovec_count) { 455 struct iov_iter i; 456 struct iovec *iov = NULL; 457 458 ret = import_iovec(rq_data_dir(rq), hdr->dxferp, 459 hdr->iovec_count, 0, &iov, &i); 460 if (ret < 0) 461 goto out_put_request; 462 463 /* SG_IO howto says that the shorter of the two wins */ 464 iov_iter_truncate(&i, hdr->dxfer_len); 465 466 ret = blk_rq_map_user_iov(rq->q, rq, NULL, &i, GFP_KERNEL); 467 kfree(iov); 468 } else if (hdr->dxfer_len) 469 ret = blk_rq_map_user(rq->q, rq, NULL, hdr->dxferp, 470 hdr->dxfer_len, GFP_KERNEL); 471 472 if (ret) 473 goto out_put_request; 474 475 bio = rq->bio; 476 scmd->allowed = 0; 477 478 start_time = jiffies; 479 480 blk_execute_rq(rq, at_head); 481 482 hdr->duration = jiffies_to_msecs(jiffies - start_time); 483 484 ret = scsi_complete_sghdr_rq(rq, hdr, bio); 485 486 out_put_request: 487 scsi_free_cmnd(scmd); 488 return ret; 489 } 490 -- 0-DAY CI Kernel Test Service https://01.org/lkp