Re: [PATCH 1/2] scsi: fix max discard sectors calculation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/16/2016 05:44 PM, Bart Van Assche wrote:
> On 05/16/2016 11:46 AM, mchristi@xxxxxxxxxx wrote:
>> logical_block_size and max_blocks are 32 bits, so we can
>> overflow when trying to convert SCSI device blocks to linux
>> block layer sectors.
>>
>> Signed-off-by: Mike Christie <mchristi@xxxxxxxxxx>
>> Cc: stable@xxxxxxxxxxxxxxx
>>
>> ---
>>   drivers/scsi/sd.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
>> index f52b74c..1668e1d 100644
>> --- a/drivers/scsi/sd.c
>> +++ b/drivers/scsi/sd.c
>> @@ -690,7 +690,8 @@ static void sd_config_discard(struct scsi_disk
>> *sdkp, unsigned int mode)
>> -    blk_queue_max_discard_sectors(q, max_blocks * (logical_block_size
>> >> 9));
>> +    blk_queue_max_discard_sectors(q, (u64)max_blocks *
>> +                      (logical_block_size >> 9));
> 
> Hello Mike,
> 
> As far as I can see max_blocks <= 0xffff (SD_MAX_WS10_BLOCKS) and 512 <=
> logical_block_size <= 4096. How can max_blocks * (logical_block_size >>
> 9) be too large for a 32 bit integer?
> 

Oops yeah, you are right. I forgot I modified the code to test the
target patch. The patch is not needed. Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux