]> err.no Git - linux-2.6/commitdiff
[SCSI] sg: fix leak when dio setup fails
authorDouglas Gilbert <dougg@torque.net>
Tue, 28 Mar 2006 19:48:22 +0000 (14:48 -0500)
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>
Thu, 13 Apr 2006 15:13:27 +0000 (10:13 -0500)
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>
drivers/scsi/sg.c

index bfa86b378fb9659c18d25a399593f9f431dc0600..b098942445ec0c43a31b041d1d25e943d28ad55e 100644 (file)
@@ -1799,8 +1799,10 @@ sg_build_direct(Sg_request * srp, Sg_fd * sfp, int dxfer_len)
        res = st_map_user_pages(schp->buffer, mx_sc_elems,
                                (unsigned long)hp->dxferp, dxfer_len, 
                                (SG_DXFER_TO_DEV == hp->dxfer_direction) ? 1 : 0);
-       if (res <= 0)
+       if (res <= 0) {
+               sg_remove_scat(schp);
                return 1;
+       }
        schp->k_use_sg = res;
        schp->dio_in_use = 1;
        hp->info |= SG_INFO_DIRECT_IO;