diff mbox series

[02/39] scsi_ioctl: return error code when blk_rq_map_kern() fails

Message ID 20210423113944.42672-3-hare@suse.de
State New
Headers show
Series SCSI result cleanup, part 2 | expand

Commit Message

Hannes Reinecke April 23, 2021, 11:39 a.m. UTC
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.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 block/scsi_ioctl.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Bart Van Assche April 26, 2021, 3:20 a.m. UTC | #1
On 4/23/21 4:39 AM, Hannes Reinecke wrote:
> 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.


Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Christoph Hellwig April 26, 2021, 2:51 p.m. UTC | #2
On Fri, Apr 23, 2021 at 01:39:07PM +0200, Hannes Reinecke wrote:
> 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.

> 

> Signed-off-by: Hannes Reinecke <hare@suse.de>


Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 6599bac0a78c..99d58786e0d5 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -488,9 +488,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);