Skip to content

Commit

Permalink
scsi: scsi_ioctl: Return error code when blk_rq_map_kern() fails
Browse files Browse the repository at this point in the history
The callers of sg_scsi_ioctl() already check for negative return values, so
we can drop the usage of DRIVER_ERROR and return the error from
blk_rq_map_kern() instead.

Link: https://lore.kernel.org/r/20210427083046.31620-3-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Hannes Reinecke authored and Martin K. Petersen committed Jun 1, 2021
1 parent 00da6a7 commit 21eccf3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions block/scsi_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,10 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
break;
}

if (bytes && blk_rq_map_kern(q, rq, buffer, bytes, GFP_NOIO)) {
err = DRIVER_ERROR << 24;
goto error;
if (bytes) {
err = blk_rq_map_kern(q, rq, buffer, bytes, GFP_NOIO);
if (err)
goto error;
}

blk_execute_rq(disk, rq, 0);
Expand Down

0 comments on commit 21eccf3

Please sign in to comment.