Skip to content

Commit

Permalink
[PATCH] fix SG_IO bio leak
Browse files Browse the repository at this point in the history
This patch fixes bio leaks in SG_IO. rq->bio can be changed after io
completion, so we need to reset rq->bio before calling blk_rq_unmap_user()

http://marc.theaimsgroup.com/?l=linux-kernel&m=116570666807983&w=2

Signed-off-by: FUJITA Tomonori <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
fujita authored and Jens Axboe committed Dec 12, 2006
1 parent 2b02a17 commit 77d172c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions block/scsi_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ static int sg_io(struct file *file, request_queue_t *q,
struct request *rq;
char sense[SCSI_SENSE_BUFFERSIZE];
unsigned char cmd[BLK_MAX_CDB];
struct bio *bio;

if (hdr->interface_id != 'S')
return -EINVAL;
Expand Down Expand Up @@ -308,6 +309,7 @@ static int sg_io(struct file *file, request_queue_t *q,
if (ret)
goto out;

bio = rq->bio;
rq->retries = 0;

start_time = jiffies;
Expand Down Expand Up @@ -338,6 +340,7 @@ static int sg_io(struct file *file, request_queue_t *q,
hdr->sb_len_wr = len;
}

rq->bio = bio;
if (blk_rq_unmap_user(rq))
ret = -EFAULT;

Expand Down

0 comments on commit 77d172c

Please sign in to comment.