The 6- to 10-byte CDB conversion for READ (6) and WRITE (6) commands in ahci_scsi.c doesn't handle the case where the transfer length field is zero. In that case the actual length transferred is 256 sectors. Here are two suggested changes. Perhaps the first change is better/more understandable.
offset = (cdbd->rw_6.addr << 16) |
(cdbd->rw_6.addr << 8) |
len = cdbd->rw_6.length;
if (len == 0) len = 256; // this line added
An alternative would be to change a different line a little later in the file:
cdbd->rw_10.length = (len == 0) ? 1 : 0; // this line changed
cdbd->rw_10.length = (len >> 0) & 0xff; // [That could just be replaced with len]
Log in to post a comment.