[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [PATCH] block: Return the real error code in bdrv_getlength
From: |
Tuguoyi |
Subject: |
RE: [PATCH] block: Return the real error code in bdrv_getlength |
Date: |
Thu, 5 Nov 2020 05:41:00 +0000 |
Sorry, please ignore this patch, it's not a right fix
--
Best regards,
Guoyi
> -----Original Message-----
> From: tuguoyi (Cloud)
> Sent: Thursday, November 05, 2020 11:11 AM
> To: 'Kevin Wolf' <kwolf@redhat.com>; 'Max Reitz' <mreitz@redhat.com>;
> 'qemu-block@nongnu.org' <qemu-block@nongnu.org>
> Cc: 'qemu-devel@nongnu.org' <qemu-devel@nongnu.org>
> Subject: [PATCH] block: Return the real error code in bdrv_getlength
>
> The return code from bdrv_nb_sectors() should be checked before doing
> the following sanity check.
>
> Signed-off-by: Guoyi Tu <tu.guoyi@h3c.com>
> ---
> block.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/block.c b/block.c
> index 430edf7..19ebbc0 100644
> --- a/block.c
> +++ b/block.c
> @@ -5082,6 +5082,10 @@ int64_t bdrv_getlength(BlockDriverState *bs)
> {
> int64_t ret = bdrv_nb_sectors(bs);
>
> + if (ret < 0) {
> + return ret;
> + }
> +
> ret = ret > INT64_MAX / BDRV_SECTOR_SIZE ? -EFBIG : ret;
> return ret < 0 ? ret : ret * BDRV_SECTOR_SIZE;
> }
> --
> 2.7.4
>
>
> --
> Best regards,
> Guoyi
>