api, glusterfsd: Cleanup upon failure in glusterfs_ctx_defaults_init()

This got introduced due to 656711d935000c16. Coverity
also picked this up as CIDs 1256176, 1256178, 1256180.

Signed-off-by: Vijay Bellur <vbellur@redhat.com>
Change-Id: If12fa0075634383975846181917a2f9650f790e3
BUG: 789278
Reviewed-on: http://review.gluster.org/9213
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
This commit is contained in:
Vijay Bellur 2014-11-28 17:54:52 +05:30
parent 4aa63e2850
commit ecb58c9a3f
2 changed files with 20 additions and 7 deletions

View File

@ -68,13 +68,20 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)
if (!ctx) {
goto err;
}
ret = xlator_mem_acct_init (THIS, glfs_mt_end + 1);
if (ret != 0) {
gf_log(THIS->name, GF_LOG_ERROR,
"Memory accounting init failed");
return ret;
}
}
ret = xlator_mem_acct_init (THIS, glfs_mt_end + 1);
if (ret != 0) {
gf_log (THIS->name, GF_LOG_ERROR,
"Memory accounting init failed");
return ret;
}
/* reset ret to -1 so that we don't need to explicitly
* set it in all error paths before "goto err"
*/
ret = -1;
ctx->process_uuid = generate_glusterfs_ctx_id ();
if (!ctx->process_uuid) {

View File

@ -1319,6 +1319,12 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)
gf_msg(THIS->name, GF_LOG_CRITICAL, 0, glusterfsd_msg_34);
return ret;
}
/* reset ret to -1 so that we don't need to explicitly
* set it in all error paths before "goto err"
*/
ret = -1;
ctx->process_uuid = generate_glusterfs_ctx_id ();
if (!ctx->process_uuid) {
gf_msg ("", GF_LOG_CRITICAL, 0, glusterfsd_msg_13);