[Qemu-devel] [PATCH] qcow2: Fix data file error condition in qcow2_co_create()

Kevin Wolf posted 1 patch 6 years, 8 months ago
Test asan failed
Test docker-clang@ubuntu passed
Test docker-mingw@fedora passed
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20190313142519.29749-1-kwolf@redhat.com
Maintainers: Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>
block/qcow2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[Qemu-devel] [PATCH] qcow2: Fix data file error condition in qcow2_co_create()
Posted by Kevin Wolf 6 years, 8 months ago
We were trying to check whether bdrv_open_blockdev_ref() returned
success, but accidentally checked the wrong variable. Spotted by
Coverity (CID 1399703).

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/qcow2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/qcow2.c b/block/qcow2.c
index 0fc9b0561e..20aba3a4d6 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -3073,7 +3073,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
             goto out;
         }
         data_bs = bdrv_open_blockdev_ref(qcow2_opts->data_file, errp);
-        if (bs == NULL) {
+        if (data_bs == NULL) {
             ret = -EIO;
             goto out;
         }
-- 
2.20.1


Re: [Qemu-devel] [PATCH] qcow2: Fix data file error condition in qcow2_co_create()
Posted by Eric Blake 6 years, 8 months ago
On 3/13/19 9:25 AM, Kevin Wolf wrote:
> We were trying to check whether bdrv_open_blockdev_ref() returned
> success, but accidentally checked the wrong variable. Spotted by
> Coverity (CID 1399703).
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block/qcow2.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> diff --git a/block/qcow2.c b/block/qcow2.c
> index 0fc9b0561e..20aba3a4d6 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -3073,7 +3073,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
>              goto out;
>          }
>          data_bs = bdrv_open_blockdev_ref(qcow2_opts->data_file, errp);
> -        if (bs == NULL) {
> +        if (data_bs == NULL) {
>              ret = -EIO;
>              goto out;
>          }
> 

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

Re: [Qemu-devel] [PATCH] qcow2: Fix data file error condition in qcow2_co_create()
Posted by Stefano Garzarella 6 years, 8 months ago
On Wed, Mar 13, 2019 at 03:25:19PM +0100, Kevin Wolf wrote:
> We were trying to check whether bdrv_open_blockdev_ref() returned
> success, but accidentally checked the wrong variable. Spotted by
> Coverity (CID 1399703).
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block/qcow2.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>