diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2010-07-21 20:36:51 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-07-28 10:06:05 -0400 |
commit | caf19d38607108304cd8cc67ed21378017f69e8a (patch) | |
tree | ae2730729cb88b30bdd90f692b18866dc8485b7a /drivers/scsi/sg.c | |
parent | 240778e821f596a6954116107c5cc3456df84f81 (diff) |
[SCSI] sg: fix bio leak with a detached device
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>
Diffstat (limited to 'drivers/scsi/sg.c')
-rw-r--r-- | drivers/scsi/sg.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index ef752b248c4d..d4549092400c 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -729,6 +729,8 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp, | |||
729 | return k; /* probably out of space --> ENOMEM */ | 729 | return k; /* probably out of space --> ENOMEM */ |
730 | } | 730 | } |
731 | if (sdp->detached) { | 731 | if (sdp->detached) { |
732 | if (srp->bio) | ||
733 | blk_end_request_all(srp->rq, -EIO); | ||
732 | sg_finish_rem_req(srp); | 734 | sg_finish_rem_req(srp); |
733 | return -ENODEV; | 735 | return -ENODEV; |
734 | } | 736 | } |