diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2012-02-27 10:10:43 +0000 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2012-02-27 10:10:43 +0000 |
commit | 0c35eb915c463824d294a543e656a919affcfc11 (patch) | |
tree | e4a6a895b243553bdd1f1a9104524850e52db719 /daemons/lvmetad/lvmetad-core.c | |
parent | 6fa41e8a21e1f2fb8ac306abd3b94bb6823aae9f (diff) | |
download | lvm2-0c35eb915c463824d294a543e656a919affcfc11.tar.gz lvm2-0c35eb915c463824d294a543e656a919affcfc11.tar.xz lvm2-0c35eb915c463824d294a543e656a919affcfc11.zip |
Move allocation after check for vgid
so there is no mem leak on this error path.
Also actually check if the hash exists.
Diffstat (limited to 'daemons/lvmetad/lvmetad-core.c')
-rw-r--r-- | daemons/lvmetad/lvmetad-core.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c index 6b384b2c..07e9a419 100644 --- a/daemons/lvmetad/lvmetad-core.c +++ b/daemons/lvmetad/lvmetad-core.c @@ -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); |