summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendrabhat@gluster.com>2012-04-16 14:50:16 +0530
committerVijay Bellur <vijay@gluster.com>2012-04-18 23:53:51 -0700
commitf8bbf1cef9da21ea55649f5a05a88479853cd8eb (patch)
tree1cb0965e2e91ad63eeef3e2f71da654cb201949c
parent678efee04855f88919904d98176b0d7c44e543d6 (diff)
cli: do not put the frame->local to mempool since its a calloced structure
In cli, frame->local is not allocated from the internal mempool, rather its calloced. So while destroying the stack, we have to set frame->local to NULL. Otherwise if frame->local is not NULL, STACK_DESTROY will try to put it back to the mempool and thus segfault. Change-Id: I5bd17d099e16fb8e73f3250cc022008e26e28f50 BUG: 812735 Signed-off-by: Raghavendra Bhat <raghavendrabhat@gluster.com> Reviewed-on: http://review.gluster.com/3167 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Amar Tumballi <amarts@redhat.com>
-rw-r--r--cli/src/cli-cmd-peer.c10
-rw-r--r--cli/src/cli-cmd-volume.c72
-rw-r--r--cli/src/cli-cmd.h13
-rw-r--r--cli/src/cli.c4
4 files changed, 46 insertions, 53 deletions
diff --git a/cli/src/cli-cmd-peer.c b/cli/src/cli-cmd-peer.c
index 60756f31085..4ac1630e557 100644
--- a/cli/src/cli-cmd-peer.c
+++ b/cli/src/cli-cmd-peer.c
@@ -96,8 +96,8 @@ out:
if ((sent == 0) && (parse_error == 0))
cli_out ("Peer probe failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -164,8 +164,7 @@ out:
cli_out ("Peer detach failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -203,8 +202,7 @@ out:
cli_out ("Peer status failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index c3222547db1..3f76b6150da 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -104,9 +104,8 @@ out:
if ((sent == 0) && (parse_error == 0))
cli_out ("Getting Volume information failed!");
}
- frame->local = NULL;
- if (frame)
- STACK_DESTROY (frame->root);
+
+ CLI_STACK_DESTROY (frame);
return ret;
@@ -175,8 +174,8 @@ out:
if (dict)
dict_unref (dict);
- if (frame)
- STACK_DESTROY (frame->root);
+
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -404,8 +403,7 @@ out:
cli_out ("Volume create failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -458,8 +456,7 @@ out:
cli_out ("Volume delete failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -538,8 +535,7 @@ out:
cli_out ("Volume start failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -661,8 +657,7 @@ out:
if (dict)
dict_unref (dict);
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -720,8 +715,7 @@ out:
cli_out ("Volume rename on '%s' failed", (char *)words[2]);
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -814,8 +808,7 @@ out:
cli_out ("Volume rebalance failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -860,8 +853,7 @@ out:
cli_out ("Volume reset failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
@@ -907,8 +899,7 @@ out:
cli_out ("Volume profile failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
@@ -954,8 +945,7 @@ out:
cli_out ("Volume set failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
@@ -1019,8 +1009,7 @@ out:
cli_out ("Volume add-brick failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -1074,8 +1063,7 @@ out:
if (ret && parse_err == 0)
cli_out ("Quota command failed");
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
@@ -1136,8 +1124,7 @@ out:
if (options)
dict_unref (options);
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
@@ -1188,8 +1175,7 @@ out:
cli_out ("Volume replace-brick failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -1244,8 +1230,7 @@ out:
cli_out ("Volume top failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
@@ -1293,8 +1278,7 @@ out:
cli_out ("Volume log rotate failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -1398,8 +1382,7 @@ out:
if (ret && parse_err == 0)
cli_out (GEOREP" command failed");
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -1447,8 +1430,7 @@ cli_cmd_volume_status_cbk (struct cli_state *state,
if (dict)
dict_unref (dict);
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -1677,8 +1659,7 @@ out:
if (options)
dict_unref (options);
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -1732,8 +1713,7 @@ out:
cli_out ("Volume statedump failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -1763,8 +1743,7 @@ out:
cli_out ("Volume list failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -1820,8 +1799,7 @@ out:
cli_out ("Volume clear-locks failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
diff --git a/cli/src/cli-cmd.h b/cli/src/cli-cmd.h
index 82e0ff113a4..ba877e2c496 100644
--- a/cli/src/cli-cmd.h
+++ b/cli/src/cli-cmd.h
@@ -30,6 +30,19 @@
#include "cli.h"
#include "list.h"
+#define CLI_STACK_DESTROY(_frame) \
+ do { \
+ if (_frame) { \
+ if (_frame->local) { \
+ gf_log ("cli", GF_LOG_DEBUG, "frame->local " \
+ "is not NULL (%p)", _frame->local); \
+ cli_local_wipe (_frame->local); \
+ _frame->local = NULL; \
+ } \
+ STACK_DESTROY (_frame->root); \
+ } \
+ } while (0);
+
typedef enum {
GF_ANSWER_YES = 1,
GF_ANSWER_NO = 2
diff --git a/cli/src/cli.c b/cli/src/cli.c
index c638dc82724..7a490fed2b9 100644
--- a/cli/src/cli.c
+++ b/cli/src/cli.c
@@ -543,6 +543,10 @@ void
cli_local_wipe (cli_local_t *local)
{
if (local) {
+ if (local->get_vol.volname)
+ GF_FREE (local->get_vol.volname);
+ if (local->dict)
+ dict_unref (local->dict);
GF_FREE (local);
}