# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	1.641   -> 1.642  
#	drivers/usb/storage/transport.c	1.25    -> 1.26   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/07/15	mdharm-usb@one-eyed-alien.net	1.642
# [PATCH] usb-storage: catch bad commands
# 
# 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.
# --------------------------------------------
#
diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
--- a/drivers/usb/storage/transport.c	Mon Jul 15 18:05:04 2002
+++ b/drivers/usb/storage/transport.c	Mon Jul 15 18:05:04 2002
@@ -344,6 +344,12 @@
 			   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;
 }
 
