On Wed, 2017-02-15 at 11:12 +0900, Damien Le Moal wrote: > + resid = round_up(resid, sector_size); > + if (resid < good_bytes) > + good_bytes -= resid; > + else > + good_bytes = 0; > + scsi_set_resid(SCpnt, resid); Hello Damien, If the Data-Out buffer is smaller than a single logical block, can the above code cause resid to exceed the Data-Out buffer size? I think we should avoid to convert a residual overflow into a residual underflow. Additionally, will round_up() work correctly if resid is negative (residual underflow)? How about using the following (untested) code instead of the above? if (resid > 0) { resid = min(good_bytes, round_up(resid, sector_size)); good_bytes -= resid; scsi_set_resid(SCpnt, resid); } Thanks, Bart.