The logical block size need to be smaller than the max_hw_sector
setting, otherwise we can't even transfer a single LBA.

Signed-off-by: Hannes Reinecke <[email protected]>
---
 block/blk-settings.c | 2 ++
 1 file changed, 2 insertions(+)

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);
 
-- 
2.35.3


Reply via email to