diff mbox

[1/2] block: Don't use error_abort in blk_new_open

Message ID 20170303133816.30303-2-famz@redhat.com
State New
Headers show

Commit Message

Fam Zheng March 3, 2017, 1:38 p.m. UTC
We have an errp and bdrv_root_attach_child can fail permission check,
error_abort is not the best choice here.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 block/block-backend.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Kevin Wolf March 6, 2017, 4:32 p.m. UTC | #1
Am 03.03.2017 um 14:38 hat Fam Zheng geschrieben:
> We have an errp and bdrv_root_attach_child can fail permission check,
> error_abort is not the best choice here.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  block/block-backend.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/block/block-backend.c b/block/block-backend.c
> index daa7908..4eab68f 100644
> --- a/block/block-backend.c
> +++ b/block/block-backend.c
> @@ -213,7 +213,11 @@ BlockBackend *blk_new_open(const char *filename, const char *reference,
>      }
>  
>      blk->root = bdrv_root_attach_child(bs, "root", &child_root,
> -                                       perm, BLK_PERM_ALL, blk, &error_abort);
> +                                       perm, BLK_PERM_ALL, blk, errp);
> +    if (!blk->root) {
> +        blk_unref(blk);
> +        return NULL;
> +    }

Shouldn't we bdrv_unref(bs), too?

Kevin
diff mbox

Patch

diff --git a/block/block-backend.c b/block/block-backend.c
index daa7908..4eab68f 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -213,7 +213,11 @@  BlockBackend *blk_new_open(const char *filename, const char *reference,
     }
 
     blk->root = bdrv_root_attach_child(bs, "root", &child_root,
-                                       perm, BLK_PERM_ALL, blk, &error_abort);
+                                       perm, BLK_PERM_ALL, blk, errp);
+    if (!blk->root) {
+        blk_unref(blk);
+        return NULL;
+    }
 
     return blk;
 }