diff options
| author | Mohammed Rafi KC <rkavunga@redhat.com> | 2016-06-03 12:44:14 +0530 | 
|---|---|---|
| committer | Jeff Darcy <jdarcy@redhat.com> | 2016-06-14 03:47:48 -0700 | 
| commit | 547563d284e40fc9cdecda4c1ecde372ed1a01c5 (patch) | |
| tree | 27233d9233c7920283d2958a2377c91cf023a85c | |
| parent | c158742fb52ae1f6d3576c64caf42b67d784a3e3 (diff) | |
glusterd/snapshot: free resource from the owner of memory
We are freeing memory from a function which is not the
owner of the memory.
Free should happen from the owner of resources.
Change-Id: If8772ba27f9eb65881dcdddde8d7dc431c1c0ee8
BUG: 1341796
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
Reviewed-on: http://review.gluster.org/14634
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Smoke: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-snapshot.c | 29 | 
1 files changed, 7 insertions, 22 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index 7967722d798..5d5bdead416 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -5179,16 +5179,6 @@ glusterd_snap_clear_unsupported_opt (glusterd_volinfo_t *volinfo,          ret = 0;  out: -        if (ret) { -                for (i = 0; unsupported_opt[i].key; i++) { -                        if (unsupported_opt[i].value) { -                                /* Freeing the memory */ -                                GF_FREE (unsupported_opt[i].value); -                                unsupported_opt[i].value = NULL; -                        } -                } -        } -          return ret;  } @@ -5212,20 +5202,11 @@ glusterd_snap_set_unsupported_opt (glusterd_volinfo_t *volinfo,                                  GD_MSG_DICT_SET_FAILED, "dict set failed");                          goto out;                  } +                unsupported_opt[i].value = NULL;          }          ret = 0;  out: -        if (ret) { -                for (; unsupported_opt[i].key; i++) { -                        if (unsupported_opt[i].value) { -                                /* Freeing the memory */ -                                GF_FREE (unsupported_opt[i].value); -                                unsupported_opt[i].value = NULL; -                        } -                } -        } -          return ret;  } @@ -5247,8 +5228,9 @@ glusterd_do_snap_vol (glusterd_volinfo_t *origin_vol, glusterd_snap_t *snap,          int64_t                      brick_order             = 0;          char                        *clonename               = NULL;          gf_boolean_t                 conf_present            = _gf_false; +        int                          i                       = 0; -       struct  gd_snap_unsupported_opt_t  unsupported_opt[]  = { +        struct  gd_snap_unsupported_opt_t  unsupported_opt[] = {                                           {.key   = VKEY_FEATURES_QUOTA,                                            .value = NULL},                                           {.key   = VKEY_FEATURES_INODE_QUOTA, @@ -5259,7 +5241,7 @@ glusterd_do_snap_vol (glusterd_volinfo_t *origin_vol, glusterd_snap_t *snap,                                            .value = NULL},                                           {.key   = NULL,                                            .value = NULL} -                                                         }; +                                                               };          this = THIS;          GF_ASSERT (this); @@ -5468,6 +5450,9 @@ reset_option:          }  out:          if (ret) { +                for (i = 0; unsupported_opt[i].key; i++) +                        GF_FREE (unsupported_opt[i].value); +                  if (snap_vol)                          glusterd_snap_volume_remove (rsp_dict, snap_vol,                                                       _gf_true, _gf_true);  | 
