diff options
author | Raghavendra G <raghavendra@gluster.com> | 2010-09-15 00:27:10 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-09-15 00:06:37 -0700 |
commit | abf28c8fd12f662f32c1a81f84620f562de8f14b (patch) | |
tree | e3d91d68aa1795535b6b7899cb9b31bfc6b2eb4d /xlators/protocol/server/src | |
parent | cfbbf68f8af83521b41b40c07db48897b976b626 (diff) |
memory leak fixes.
- free memory allocated by libc when decoding request arguments in server and
reply in client.
- free memory allocated to saved_frames during connection cleanup.
- free memory allocated for transport name while creating listeners.
Signed-off-by: Raghavendra G <raghavendra@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 1438 (memory leaks)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1438
Diffstat (limited to 'xlators/protocol/server/src')
-rw-r--r-- | xlators/protocol/server/src/server-handshake.c | 18 | ||||
-rw-r--r-- | xlators/protocol/server/src/server3_1-fops.c | 49 |
2 files changed, 64 insertions, 3 deletions
diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c index 98ec18cc2e9..b148f06690d 100644 --- a/xlators/protocol/server/src/server-handshake.c +++ b/xlators/protocol/server/src/server-handshake.c @@ -355,6 +355,7 @@ server_setvolume (rpcsvc_request_t *req) int32_t op_errno = EINVAL; int32_t fop_version = 0; int32_t mgmt_version = 0; + char *buf = NULL; params = dict_new (); reply = dict_new (); @@ -369,7 +370,15 @@ server_setvolume (rpcsvc_request_t *req) config_params = dict_copy_with_ref (this->options, NULL); conf = this->private; - ret = dict_unserialize (args.dict.dict_val, args.dict.dict_len, ¶ms); + buf = memdup (args.dict.dict_val, args.dict.dict_len); + if (buf == NULL) { + gf_log (this->name, GF_LOG_ERROR, "out of memory"); + op_ret = -1; + op_errno = ENOMEM; + goto fail; + } + + ret = dict_unserialize (buf, args.dict.dict_len, ¶ms); if (ret < 0) { ret = dict_set_str (reply, "ERROR", "Internal error: failed to unserialize " @@ -385,6 +394,9 @@ server_setvolume (rpcsvc_request_t *req) goto fail; } + params->extra_free = buf; + buf = NULL; + ret = dict_get_str (params, "process-uuid", &process_uuid); if (ret < 0) { ret = dict_set_str (reply, "ERROR", @@ -622,6 +634,10 @@ fail: dict_unref (reply); dict_unref (config_params); + if (buf) { + GF_FREE (buf); + } + return 0; } diff --git a/xlators/protocol/server/src/server3_1-fops.c b/xlators/protocol/server/src/server3_1-fops.c index 5be50475719..1ced00a4bc2 100644 --- a/xlators/protocol/server/src/server3_1-fops.c +++ b/xlators/protocol/server/src/server3_1-fops.c @@ -2904,6 +2904,12 @@ server_create (rpcsvc_request_t *req) memcpy (state->resolve.pargfid, args.pargfid, 16); resolve_and_resume (frame, server_create_resume); + + /* memory allocated by libc, don't use GF_FREE */ + if (args.dict.dict_val != NULL) { + free (args.dict.dict_val); + } + return 0; out: if (params) @@ -2912,8 +2918,13 @@ out: if (buf) { GF_FREE (buf); } - return 0; + /* memory allocated by libc, don't use GF_FREE */ + if (args.dict.dict_val != NULL) { + free (args.dict.dict_val); + } + + return 0; } @@ -4109,6 +4120,12 @@ server_mknod (rpcsvc_request_t *req) state->dev = args.dev; resolve_and_resume (frame, server_mknod_resume); + + /* memory allocated by libc, don't use GF_FREE */ + if (args.dict.dict_val != NULL) { + free (args.dict.dict_val); + } + return 0; out: if (params) @@ -4117,6 +4134,12 @@ out: if (buf) { GF_FREE (buf); } + + /* memory allocated by libc, don't use GF_FREE */ + if (args.dict.dict_val != NULL) { + free (args.dict.dict_val); + } + return 0; } @@ -4197,6 +4220,12 @@ server_mkdir (rpcsvc_request_t *req) state->mode = args.mode; resolve_and_resume (frame, server_mkdir_resume); + + if (args.dict.dict_val != NULL) { + /* memory allocated by libc, don't use GF_FREE */ + free (args.dict.dict_val); + } + return 0; out: if (params) @@ -4205,8 +4234,13 @@ out: if (buf) { GF_FREE (buf); } - return 0; + if (args.dict.dict_val != NULL) { + /* memory allocated by libc, don't use GF_FREE */ + free (args.dict.dict_val); + } + + return 0; } @@ -4631,6 +4665,11 @@ server_symlink (rpcsvc_request_t *req) state->name = gf_strdup (args.linkname); resolve_and_resume (frame, server_symlink_resume); + + /* memory allocated by libc, don't use GF_FREE */ + if (args.dict.dict_val != NULL) { + free (args.dict.dict_val); + } return 0; out: if (params) @@ -4639,6 +4678,12 @@ out: if (buf) { GF_FREE (buf); } + + /* memory allocated by libc, don't use GF_FREE */ + if (args.dict.dict_val != NULL) { + free (args.dict.dict_val); + } + return 0; } |