]> sourceware.org Git - lvm2.git/commitdiff
Move allocation after check for vgid
authorZdenek Kabelac <zkabelac@redhat.com>
Mon, 27 Feb 2012 10:10:43 +0000 (10:10 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 27 Feb 2012 10:10:43 +0000 (10:10 +0000)
so there is no mem leak on this error path.
Also actually check if the hash exists.

daemons/lvmetad/lvmetad-core.c

index 6b384b2cdf0ee98e070d1ef2a930119e5d342faa..07e9a4197526172055c55418646517f3c43c6141 100644 (file)
@@ -548,7 +548,7 @@ static int update_pvid_to_vgid(lvmetad_state *s, struct dm_config_tree *vg,
                               const char *vgid, int nuke_empty)
 {
        struct dm_config_node *pv = pvs(vg->root);
-       struct dm_hash_table *to_check = dm_hash_create(32);
+       struct dm_hash_table *to_check;
        struct dm_hash_node *n;
        const char *pvid;
        const char *vgid_old;
@@ -556,6 +556,9 @@ static int update_pvid_to_vgid(lvmetad_state *s, struct dm_config_tree *vg,
        if (!vgid)
                return 0;
 
+       if (!(to_check = dm_hash_create(32)))
+               return 0;
+
        while (pv) {
                pvid = dm_config_find_str(pv->child, "id", NULL);
                vgid_old = dm_hash_lookup(s->pvid_to_vgid, pvid);
This page took 0.038427 seconds and 5 git commands to generate.