From: Bart Van Assche <bvanassche@acm.org>
To: Hannes Reinecke <hare@kernel.org>, Jens Axboe <axboe@kernel.dk>
Cc: Christoph Hellwig <hch@lst.de>, Mike Snitzer <snitzer@kernel.org>,
linux-block@vger.kernel.org, dm-devel@lists.linux.dev
Subject: Re: [PATCH] block: check for max_hw_sectors underflow
Date: Fri, 24 May 2024 06:49:40 -0700 [thread overview]
Message-ID: <cbfd280d-188e-4dc9-82a0-4052e58a4bb2@acm.org> (raw)
In-Reply-To: <20240524095719.105284-1-hare@kernel.org>
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.
prev parent reply other threads:[~2024-05-24 13:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cbfd280d-188e-4dc9-82a0-4052e58a4bb2@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=dm-devel@lists.linux.dev \
--cc=hare@kernel.org \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=snitzer@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox