Commit 5c0f6137 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Martin K. Petersen
Browse files

scsi: bsg: Fix commands without data transfer in scsi_bsg_sg_io_fn()

Set ret to 0 after the initial permission checks to avoid leaking -EPERM
for commands without data transfer.

Link: https://lore.kernel.org/r/20210731074027.1185545-2-hch@lst.de


Fixes: 75ca5640 ("scsi: bsg: Move the whole request execution into the SCSI/transport handlers")
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 1084514c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ static int scsi_bsg_sg_io_fn(struct request_queue *q, struct sg_io_v4 *hdr,
	if (!scsi_cmd_allowed(sreq->cmd, mode))
		goto out_free_cmd;

	ret = 0;
	if (hdr->dout_xfer_len) {
		ret = blk_rq_map_user(rq->q, rq, NULL, uptr64(hdr->dout_xferp),
				hdr->dout_xfer_len, GFP_KERNEL);