Skip to content

Commit

Permalink
[SCSI] sg: fix bio leak with a detached device
Browse files Browse the repository at this point in the history
After blk_rq_map_user is successful, if we find that a device is
unavailable (was detached), we must call blk_end_request_all to free
bio(s) before blk_rq_unmap_user and blk_put_request.

Reported-by: "Dailey, Nate" <Nate.Dailey@stratus.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Tested-by: "Dailey, Nate" <Nate.Dailey@stratus.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
  • Loading branch information
FUJITA Tomonori authored and James Bottomley committed Jul 28, 2010
1 parent 240778e commit caf19d3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/scsi/sg.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,8 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
return k; /* probably out of space --> ENOMEM */
}
if (sdp->detached) {
if (srp->bio)
blk_end_request_all(srp->rq, -EIO);
sg_finish_rem_req(srp);
return -ENODEV;
}
Expand Down

0 comments on commit caf19d3

Please sign in to comment.