Skip to content

Commit

Permalink
block: fix SG_IO to return a proper error value
Browse files Browse the repository at this point in the history
blk_rq_unmap_user() returns -EFAULT if a program passes an invalid
address to kernel. SG_IO path needs to pass the returned value to user
space instead of ignoring it.

Signed-off-by: FUJITA Tomonori <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
fujita authored and Jens Axboe committed Apr 15, 2009
1 parent d6ceb25 commit 91e463c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions block/scsi_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,
struct bio *bio)
{
int ret = 0;
int r, ret = 0;

/*
* fill in all the output members
Expand All @@ -242,7 +242,9 @@ static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,
ret = -EFAULT;
}

blk_rq_unmap_user(bio);
r = blk_rq_unmap_user(bio);
if (!ret)
ret = r;
blk_put_request(rq);

return ret;
Expand Down

0 comments on commit 91e463c

Please sign in to comment.