[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] block: Fix max nb_sectors in bdrv_make_zero
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH] block: Fix max nb_sectors in bdrv_make_zero |
Date: |
Mon, 10 Nov 2014 09:33:02 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Fam Zheng <address@hidden> writes:
> In bdrv_rw_co we report -EINVAL for nb_sectors > INT_MAX /
> BDRV_SECTOR_SIZE, so a caller shouldn't exceed it.
It's not obvious to me why we do that there. iovec member iov_len is
size_t, not int.
> Signed-off-by: Fam Zheng <address@hidden>
> ---
> block.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/block.c b/block.c
> index dacd881..5513379 100644
> --- a/block.c
> +++ b/block.c
> @@ -2790,8 +2790,8 @@ int bdrv_make_zero(BlockDriverState *bs,
> BdrvRequestFlags flags)
> if (nb_sectors <= 0) {
> return 0;
> }
> - if (nb_sectors > INT_MAX) {
> - nb_sectors = INT_MAX;
> + if (nb_sectors > INT_MAX / BDRV_SECTOR_SIZE) {
> + nb_sectors = INT_MAX / BDRV_SECTOR_SIZE;
> }
> ret = bdrv_get_block_status(bs, sector_num, nb_sectors, &n);
> if (ret < 0) {
Noticed while checkout out bdrv_get_block_status(): function comment of
bdrv_co_get_block_status() claims it returns true/false. It doesn't.