[PATCH] fix bdrv_open_child return value check

Dmitry Frolov posted 1 patch 8 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20230831125926.796205-1-frolov@swemel.ru
Maintainers: Fam Zheng <fam@euphon.net>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>
block/vmdk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] fix bdrv_open_child return value check
Posted by Dmitry Frolov 8 months ago
bdrv_open_child() may return NULL.
Usually return value is checked for this function.
Check for return value is more reliable.

Fixes: 24bc15d1f6 ("vmdk: Use BdrvChild instead of BDS for references to extents")

Signed-off-by: Dmitry Frolov <frolov@swemel.ru>
---
 block/vmdk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/vmdk.c b/block/vmdk.c
index 70066c2b01..58ce290e9c 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -1207,7 +1207,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
                                       bs, &child_of_bds, extent_role, false,
                                       &local_err);
         g_free(extent_path);
-        if (local_err) {
+        if (!extent_file) {
             error_propagate(errp, local_err);
             ret = -EINVAL;
             goto out;
-- 
2.34.1
Re: [PATCH] fix bdrv_open_child return value check
Posted by Kevin Wolf 8 months ago
Am 31.08.2023 um 14:59 hat Dmitry Frolov geschrieben:
> bdrv_open_child() may return NULL.
> Usually return value is checked for this function.
> Check for return value is more reliable.
> 
> Fixes: 24bc15d1f6 ("vmdk: Use BdrvChild instead of BDS for references to extents")
> 
> Signed-off-by: Dmitry Frolov <frolov@swemel.ru>

Did you actually see some failure because of this? If so, what is the
specific case that failed?

Or is this just cleanup based on code inspection?

Kevin
Re: [PATCH] fix bdrv_open_child return value check
Posted by Дмитрий Фролов 8 months ago
Hello, Kevin.

This was just cleanup, based on the inspection.

Dmitry.

01.09.2023 14:15, Kevin Wolf пишет:
> Am 31.08.2023 um 14:59 hat Dmitry Frolov geschrieben:
>> bdrv_open_child() may return NULL.
>> Usually return value is checked for this function.
>> Check for return value is more reliable.
>>
>> Fixes: 24bc15d1f6 ("vmdk: Use BdrvChild instead of BDS for references to extents")
>>
>> Signed-off-by: Dmitry Frolov <frolov@swemel.ru>
> Did you actually see some failure because of this? If so, what is the
> specific case that failed?
>
> Or is this just cleanup based on code inspection?
>
> Kevin
>


Re: [PATCH] fix bdrv_open_child return value check
Posted by Kevin Wolf 8 months ago
Am 01.09.2023 um 13:26 hat Дмитрий Фролов geschrieben:
> Hello, Kevin.
> 
> This was just cleanup, based on the inspection.

Thanks for clarifying. I've updated the subject line to "vmdk: Clean up
bdrv_open_child() return value check" to avoid misunderstandings and
applied this to my block branch.

Kevin