public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: check for max_hw_sectors underflow
@ 2024-05-24  9:57 Hannes Reinecke
  2024-05-24  9:58 ` Christoph Hellwig
  2024-05-24 13:49 ` Bart Van Assche
  0 siblings, 2 replies; 3+ messages in thread
From: Hannes Reinecke @ 2024-05-24  9:57 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Christoph Hellwig, Mike Snitzer, linux-block, dm-devel,
	Hannes Reinecke

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 <hare@kernel.org>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-24 13:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-24  9:57 [PATCH] block: check for max_hw_sectors underflow Hannes Reinecke
2024-05-24  9:58 ` Christoph Hellwig
2024-05-24 13:49 ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox