]> git.hungrycats.org Git - linux/commitdiff
[PATCH] usb-storage: catch bad commands
authorMatthew Dharm <mdharm-usb@one-eyed-alien.net>
Mon, 15 Jul 2002 10:19:17 +0000 (03:19 -0700)
committerVojtech Pavlik <vojtech@suse.cz>
Mon, 15 Jul 2002 10:19:17 +0000 (03:19 -0700)
The purpose of this patch is to trap all commands which have a bogus
request_bufflen.  Much logic is devoted to calculating the proper length of
the transfer, but according to discussions I've had on linux-scsi, this is
really a bug in whatever is originating the bad command.

Hopefully, after people use this patch for a while, we'll eliminate all the
offending sources and can remove quite a bit of logic from the driver.

drivers/usb/storage/transport.c

index 9b22b2acb40c1bced9ee99e1d912d41bf9f16583..8c3baaabfb028da41841fad35a3eb9c9b3a2ebd7 100644 (file)
@@ -344,6 +344,12 @@ unsigned int usb_stor_transfer_length(Scsi_Cmnd *srb)
                           len = srb->request_bufflen;
           }
 
+       /* According to the linux-scsi people, any command sent which
+        * violates this invariant is a bug.  In the hopes of removing
+        * all the complex logic above, let's find them and eliminate them.
+        */
+       BUG_ON(len != srb->request_bufflen);
+
        return len;
 }