From 6fa91667b6f5555c7ad5f065d72cb28e5ee9df4e Mon Sep 17 00:00:00 2001 From: Matthew Dharm Date: Mon, 15 Jul 2002 03:19:17 -0700 Subject: [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. --- drivers/usb/storage/transport.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers') diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index 9b22b2acb40c..8c3baaabfb02 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c @@ -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; } -- cgit v1.2.3