[PATCH] block: Return the real error code in bdrv_getlength

Tuguoyi posted 1 patch 5 years ago
Failed in applying to current master (apply log)
block.c | 4 ++++
1 file changed, 4 insertions(+)
[PATCH] block: Return the real error code in bdrv_getlength
Posted by Tuguoyi 5 years ago
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


Re: [PATCH] block: Return the real error code in bdrv_getlength
Posted by Eric Blake 5 years ago
On 11/4/20 9:10 PM, Tuguoyi wrote:
> 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>

It looks like you sent several variations on this patch.  A
meta-observation: your mailer is attributing the patch to the spelling
"Tuguoyi", while your S-o-b line is spelling "Guoyi Tu".  It's worth
being consistent between the two.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org