]> git.karo-electronics.de Git - karo-tx-linux.git/commit
SCSI: fix BUG when sum(scatterlist) > bufflen
authorTony Battersby <tonyb@cybernetics.com>
Wed, 5 Mar 2008 16:23:26 +0000 (10:23 -0600)
committerChris Wright <chrisw@sous-sol.org>
Mon, 24 Mar 2008 18:47:38 +0000 (11:47 -0700)
commitb9c98c2a4580b94021266bbf3f4a70b6ca030558
treebf0ae6c4f5123fdc1a54c9274a1c43381f7cf34b
parent5475187c2752adcc6d789592b5f68c81c39e5a81
SCSI: fix BUG when sum(scatterlist) > bufflen

commit: 4d2de3a50ce19af2008a90636436a1bf5b3b697b

When sending a SCSI command to a tape drive via the SCSI Generic (sg)
driver, if the command has a data transfer length more than
scatter_elem_sz (32 KB default) and not a multiple of 512, then I either
hit BUG_ON(!valid_dma_direction(direction)) in dma_unmap_sg() or else
the command never completes (depending on the LLDD).

When constructing scatterlists, the sg driver rounds up the scatterlist
element sizes to be a multiple of 512.  This can result in
sum(scatterlist lengths) > bufflen.  In this case, scsi_req_map_sg()
incorrectly sets bio->bi_size to sum(scatterlist lengths) rather than to
bufflen.  When the command completes, req_bio_endio() detects that
bio->bi_size != 0, and so it doesn't call bio_endio().  This causes the
command to be resubmitted, resulting in BUG_ON or the command never
completing.

This patch makes scsi_req_map_sg() set bio->bi_size to bufflen rather
than to sum(scatterlist lengths), which fixes the problem.

Signed-off-by: Tony Battersby <tonyb@cybernetics.com>
Acked-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/scsi/scsi_lib.c