diff options
author | Douglas Gilbert <dougg@torque.net> | 2006-03-28 14:48:22 -0500 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-04-13 11:13:27 -0400 |
commit | c06bb7f514567efa39062a781679120e51caa818 (patch) | |
tree | d58b61ab78469e7d4a94935ad8169c9764b9f54a /drivers | |
parent | d6159c17c2c76963a8067d1e1ac3c4c36c05e674 (diff) |
[SCSI] sg: fix leak when dio setup fails
when the sg driver is unable to setup direct IO, free that scatter
gather list prior to falling back to indirect IO
Further to this thread started by Bryan Holty:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114306885116728&w=2
Here is the reworked patch again. This time it has been
tested with a program provided by Bryan.
Signed-off-by: Douglas Gilbert <dougg@torque.net>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/sg.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index bfa86b378fb9..b098942445ec 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -1799,8 +1799,10 @@ sg_build_direct(Sg_request * srp, Sg_fd * sfp, int dxfer_len) | |||
1799 | res = st_map_user_pages(schp->buffer, mx_sc_elems, | 1799 | res = st_map_user_pages(schp->buffer, mx_sc_elems, |
1800 | (unsigned long)hp->dxferp, dxfer_len, | 1800 | (unsigned long)hp->dxferp, dxfer_len, |
1801 | (SG_DXFER_TO_DEV == hp->dxfer_direction) ? 1 : 0); | 1801 | (SG_DXFER_TO_DEV == hp->dxfer_direction) ? 1 : 0); |
1802 | if (res <= 0) | 1802 | if (res <= 0) { |
1803 | sg_remove_scat(schp); | ||
1803 | return 1; | 1804 | return 1; |
1805 | } | ||
1804 | schp->k_use_sg = res; | 1806 | schp->k_use_sg = res; |
1805 | schp->dio_in_use = 1; | 1807 | schp->dio_in_use = 1; |
1806 | hp->info |= SG_INFO_DIRECT_IO; | 1808 | hp->info |= SG_INFO_DIRECT_IO; |