Re: [PATCH] block: check for max_hw_sectors underflow

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

 



On 5/24/24 02:57, Hannes Reinecke wrote:
diff --git a/block/blk-settings.c b/block/blk-settings.c
index 524cf597b2e9..0cdca702e988 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -133,6 +133,8 @@ static int blk_validate_limits(struct queue_limits *lim)
  		lim->max_hw_sectors = BLK_SAFE_MAX_SECTORS;
  	if (WARN_ON_ONCE(lim->max_hw_sectors < PAGE_SECTORS))
  		return -EINVAL;
+	if (WARN_ON_ONCE((lim->logical_block_size >> SECTOR_SHIFT) > lim->max_hw_sectors))
+		return -EINVAL;
  	lim->max_hw_sectors = round_down(lim->max_hw_sectors,
  			lim->logical_block_size >> SECTOR_SHIFT);

Why is lim->max_hw_sectors checked before calling round_down() instead
of checking that round_down() returns zero?

Thanks,

Bart.




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux