tree: https://github.com/ammarfaizi2/linux-block viro/vfs/untested.blk-map head: a4d354f96b0ba54c70a420f797477619a550cecf commit: e988b46f35821f08cafe55c89ddb4b5fcbcc05b1 [10/22] sg_io(): switch to setting bio chain first config: m68k-allyesconfig compiler: m68k-linux-gcc (GCC) 12.1.0 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/ammarfaizi2/linux-block/commit/e988b46f35821f08cafe55c89ddb4b5fcbcc05b1 git remote add ammarfaizi2-block https://github.com/ammarfaizi2/linux-block git fetch --no-tags ammarfaizi2-block viro/vfs/untested.blk-map git checkout e988b46f35821f08cafe55c89ddb4b5fcbcc05b1 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash drivers/scsi/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot All warnings (new ones prefixed by >>): drivers/scsi/scsi_ioctl.c: In function 'sg_io': >> drivers/scsi/scsi_ioctl.c:394:13: warning: variable 'writing' set but not used [-Wunused-but-set-variable] 394 | int writing = 0; | ^~~~~~~ vim +/writing +394 drivers/scsi/scsi_ioctl.c f2542a3be3277a Christoph Hellwig 2021-07-24 389 a30e3441325ba4 Christoph Hellwig 2021-11-26 390 static int sg_io(struct scsi_device *sdev, struct sg_io_hdr *hdr, fmode_t mode) f2542a3be3277a Christoph Hellwig 2021-07-24 391 { f2542a3be3277a Christoph Hellwig 2021-07-24 392 unsigned long start_time; f2542a3be3277a Christoph Hellwig 2021-07-24 393 ssize_t ret = 0; f2542a3be3277a Christoph Hellwig 2021-07-24 @394 int writing = 0; f2542a3be3277a Christoph Hellwig 2021-07-24 395 int at_head = 0; f2542a3be3277a Christoph Hellwig 2021-07-24 396 struct request *rq; ce70fd9a551af7 Christoph Hellwig 2022-02-24 397 struct scsi_cmnd *scmd; f2542a3be3277a Christoph Hellwig 2021-07-24 398 struct bio *bio; e988b46f35821f Al Viro 2022-12-06 399 unsigned char sense[SCSI_SENSE_BUFFERSIZE]; e988b46f35821f Al Viro 2022-12-06 400 unsigned char cmnd[sizeof(scmd->cmnd)]; e988b46f35821f Al Viro 2022-12-06 401 blk_opf_t opf = REQ_OP_DRV_IN; f2542a3be3277a Christoph Hellwig 2021-07-24 402 f2542a3be3277a Christoph Hellwig 2021-07-24 403 if (hdr->interface_id != 'S') f2542a3be3277a Christoph Hellwig 2021-07-24 404 return -EINVAL; f2542a3be3277a Christoph Hellwig 2021-07-24 405 1e61c1a804d2a2 Christoph Hellwig 2021-07-29 406 if (hdr->dxfer_len > (queue_max_hw_sectors(sdev->request_queue) << 9)) f2542a3be3277a Christoph Hellwig 2021-07-24 407 return -EIO; f2542a3be3277a Christoph Hellwig 2021-07-24 408 f2542a3be3277a Christoph Hellwig 2021-07-24 409 if (hdr->dxfer_len) f2542a3be3277a Christoph Hellwig 2021-07-24 410 switch (hdr->dxfer_direction) { f2542a3be3277a Christoph Hellwig 2021-07-24 411 default: f2542a3be3277a Christoph Hellwig 2021-07-24 412 return -EINVAL; f2542a3be3277a Christoph Hellwig 2021-07-24 413 case SG_DXFER_TO_DEV: f2542a3be3277a Christoph Hellwig 2021-07-24 414 writing = 1; e988b46f35821f Al Viro 2022-12-06 415 opf = REQ_OP_DRV_OUT; f2542a3be3277a Christoph Hellwig 2021-07-24 416 break; f2542a3be3277a Christoph Hellwig 2021-07-24 417 case SG_DXFER_TO_FROM_DEV: f2542a3be3277a Christoph Hellwig 2021-07-24 418 case SG_DXFER_FROM_DEV: f2542a3be3277a Christoph Hellwig 2021-07-24 419 break; f2542a3be3277a Christoph Hellwig 2021-07-24 420 } f2542a3be3277a Christoph Hellwig 2021-07-24 421 if (hdr->flags & SG_FLAG_Q_AT_HEAD) f2542a3be3277a Christoph Hellwig 2021-07-24 422 at_head = 1; f2542a3be3277a Christoph Hellwig 2021-07-24 423 e988b46f35821f Al Viro 2022-12-06 424 if (hdr->cmd_len > sizeof(cmnd)) e988b46f35821f Al Viro 2022-12-06 425 return -EINVAL; f2542a3be3277a Christoph Hellwig 2021-07-24 426 e988b46f35821f Al Viro 2022-12-06 427 if (hdr->cmd_len < 6) e988b46f35821f Al Viro 2022-12-06 428 return -EMSGSIZE; e988b46f35821f Al Viro 2022-12-06 429 if (copy_from_user(cmnd, hdr->cmdp, hdr->cmd_len)) e988b46f35821f Al Viro 2022-12-06 430 return -EFAULT; e988b46f35821f Al Viro 2022-12-06 431 if (!scsi_cmd_allowed(cmnd, mode)) e988b46f35821f Al Viro 2022-12-06 432 return -EPERM; f2542a3be3277a Christoph Hellwig 2021-07-24 433 e988b46f35821f Al Viro 2022-12-06 434 bio = blk_map_user_io(sdev->request_queue, opf, NULL, e988b46f35821f Al Viro 2022-12-06 435 hdr->dxferp, hdr->dxfer_len, e988b46f35821f Al Viro 2022-12-06 436 hdr->iovec_count && hdr->dxfer_len, e988b46f35821f Al Viro 2022-12-06 437 hdr->iovec_count, 0); e988b46f35821f Al Viro 2022-12-06 438 if (IS_ERR(bio)) e988b46f35821f Al Viro 2022-12-06 439 return PTR_ERR(bio); f2542a3be3277a Christoph Hellwig 2021-07-24 440 e988b46f35821f Al Viro 2022-12-06 441 rq = scsi_alloc_request(sdev->request_queue, opf, 0); e988b46f35821f Al Viro 2022-12-06 442 if (IS_ERR(rq)) { e988b46f35821f Al Viro 2022-12-06 443 blk_rq_unmap_user(bio); e988b46f35821f Al Viro 2022-12-06 444 return PTR_ERR(rq); e988b46f35821f Al Viro 2022-12-06 445 } e988b46f35821f Al Viro 2022-12-06 446 e988b46f35821f Al Viro 2022-12-06 447 blk_rq_attach_bios(rq, bio); f2542a3be3277a Christoph Hellwig 2021-07-24 448 e988b46f35821f Al Viro 2022-12-06 449 scmd = blk_mq_rq_to_pdu(rq); e988b46f35821f Al Viro 2022-12-06 450 scsi_fill_sghdr_rq(sdev, rq, hdr, cmnd); 6aded12b10e0c9 Christoph Hellwig 2022-02-24 451 scmd->allowed = 0; f2542a3be3277a Christoph Hellwig 2021-07-24 452 f2542a3be3277a Christoph Hellwig 2021-07-24 453 start_time = jiffies; f2542a3be3277a Christoph Hellwig 2021-07-24 454 b84ba30b6c7a75 Christoph Hellwig 2021-11-26 455 blk_execute_rq(rq, at_head); f2542a3be3277a Christoph Hellwig 2021-07-24 456 f2542a3be3277a Christoph Hellwig 2021-07-24 457 hdr->duration = jiffies_to_msecs(jiffies - start_time); e988b46f35821f Al Viro 2022-12-06 458 scsi_complete_sghdr_rq(rq, hdr, sense); f2542a3be3277a Christoph Hellwig 2021-07-24 459 0bf6d96cb82940 Christoph Hellwig 2021-10-25 460 blk_mq_free_request(rq); e988b46f35821f Al Viro 2022-12-06 461 ret = blk_rq_unmap_user(bio); e988b46f35821f Al Viro 2022-12-06 462 if (hdr->sb_len_wr && copy_to_user(hdr->sbp, sense, hdr->sb_len_wr)) e988b46f35821f Al Viro 2022-12-06 463 ret = -EFAULT; f2542a3be3277a Christoph Hellwig 2021-07-24 464 return ret; f2542a3be3277a Christoph Hellwig 2021-07-24 465 } f2542a3be3277a Christoph Hellwig 2021-07-24 466 :::::: The code at line 394 was first introduced by commit :::::: f2542a3be3277a65c766fa6e86b930d3d839f79e scsi: scsi_ioctl: Move the "block layer" SCSI ioctl handling to drivers/scsi :::::: TO: Christoph Hellwig :::::: CC: Martin K. Petersen -- 0-DAY CI Kernel Test Service https://01.org/lkp