Skip to content

Commit

Permalink
target: Handle 0 correctly in transport_get_sectors_6()
Browse files Browse the repository at this point in the history
SBC-3 says:

    A TRANSFER LENGTH field set to zero specifies that 256 logical
    blocks shall be written.  Any other value specifies the number
    of logical blocks that shall be written.

The old code was always just returning the value in the TRANSFER LENGTH
byte.  Fix this to return 256 if the byte is 0.

Signed-off-by: Roland Dreier <roland@purestorage.com>
Cc: stable@kernel.org
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
  • Loading branch information
Roland Dreier authored and Nicholas Bellinger committed Dec 6, 2011
1 parent 410f670 commit 9b5cd7f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/target/target_core_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -2144,10 +2144,15 @@ static inline u32 transport_get_sectors_6(

/*
* Everything else assume TYPE_DISK Sector CDB location.
* Use 8-bit sector value.
* Use 8-bit sector value. SBC-3 says:
*
* A TRANSFER LENGTH field set to zero specifies that 256
* logical blocks shall be written. Any other value
* specifies the number of logical blocks that shall be
* written.
*/
type_disk:
return (u32)cdb[4];
return cdb[4] ? : 256;
}

static inline u32 transport_get_sectors_10(
Expand Down

0 comments on commit 9b5cd7f

Please sign in to comment.