From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59674) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xnj4X-0004be-0d for qemu-devel@nongnu.org; Mon, 10 Nov 2014 02:07:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xnj4Q-0003Rl-Sx for qemu-devel@nongnu.org; Mon, 10 Nov 2014 02:07:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35257) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xnj4Q-0003RZ-LA for qemu-devel@nongnu.org; Mon, 10 Nov 2014 02:07:26 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sAA77PQh012768 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 10 Nov 2014 02:07:25 -0500 From: Fam Zheng Date: Mon, 10 Nov 2014 15:07:44 +0800 Message-Id: <1415603264-21497-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH] block: Fix max nb_sectors in bdrv_make_zero List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi In bdrv_rw_co we report -EINVAL for nb_sectors > INT_MAX / BDRV_SECTOR_SIZE, so a caller shouldn't exceed it. Signed-off-by: Fam Zheng --- 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) { -- 1.9.3