Skip to content

Commit fad7f01

Browse files
fujitaJens Axboe
authored andcommitted
sg: set dxferp to NULL for READ with the older SG interface
With the older SG interface, we don't know a user-space address to trasfer data when executing a SCSI command. So we can't pass a user-space address to blk_rq_map_user. This patch fixes sg to pass a NULL user-space address to blk_rq_map_user so that it just sets up a request and bios with page frames propely without data transfer. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
1 parent 8188276 commit fad7f01

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/scsi/sg.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,10 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
615615
else
616616
hp->dxfer_direction = (mxsize > 0) ? SG_DXFER_FROM_DEV : SG_DXFER_NONE;
617617
hp->dxfer_len = mxsize;
618-
hp->dxferp = (char __user *)buf + cmd_size;
618+
if (hp->dxfer_direction == SG_DXFER_TO_DEV)
619+
hp->dxferp = (char __user *)buf + cmd_size;
620+
else
621+
hp->dxferp = NULL;
619622
hp->sbp = NULL;
620623
hp->timeout = old_hdr.reply_len; /* structure abuse ... */
621624
hp->flags = input_size; /* structure abuse ... */

0 commit comments

Comments
 (0)