summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiels de Vos <ndevos@redhat.com>2017-04-10 10:10:30 +0200
committerJeff Darcy <jeff@pl.atyp.us>2017-04-10 11:19:24 -0400
commit88551d8567503b3eba17e54fbe7dd9ee6266c1ab (patch)
treec01193c0fe77431cd66a89a831b7dbfd60ef9f97
parent3594f960a8b5ccf81b6d06c89003f175ddd6a2c8 (diff)
upcall: correct the cleanup path in init() when GF_CALLOC() fails
Coverity found that "priv" can be NULL when the 1st GF_CALLOC() fails, and still is being used with "priv->xattrs" before the functon returns. While cleaning this up, also removing the log message for out of memory, as this is already logged through GF_CALLOC(). BUG: 789278 Change-Id: I887eaa9136dc25a39c107cd2152b1ba11f9fa925 Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: https://review.gluster.org/17023 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: soumya k <skoduri@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Amar Tumballi <amarts@redhat.com>
-rw-r--r--xlators/features/upcall/src/upcall.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/xlators/features/upcall/src/upcall.c b/xlators/features/upcall/src/upcall.c
index 40ad1c4e379..0e9919d41c4 100644
--- a/xlators/features/upcall/src/upcall.c
+++ b/xlators/features/upcall/src/upcall.c
@@ -2355,12 +2355,12 @@ init (xlator_t *this)
priv = GF_CALLOC (1, sizeof (*priv),
gf_upcall_mt_private_t);
- if (!priv) {
- gf_msg ("upcall", GF_LOG_WARNING, 0,
- UPCALL_MSG_NO_MEMORY,
- "Memory allocation failed");
+ if (!priv)
+ goto out;
+
+ priv->xattrs = dict_new ();
+ if (!priv->xattrs)
goto out;
- }
GF_OPTION_INIT ("cache-invalidation", priv->cache_invalidation_enabled,
bool, out);
@@ -2369,12 +2369,11 @@ init (xlator_t *this)
LOCK_INIT (&priv->inode_ctx_lk);
INIT_LIST_HEAD (&priv->inode_ctx_list);
- priv->xattrs = dict_new ();
- this->private = priv;
priv->fini = 0;
priv->reaper_init_done = _gf_false;
+ this->private = priv;
this->local_pool = mem_pool_new (upcall_local_t, 512);
ret = 0;
@@ -2391,8 +2390,10 @@ init (xlator_t *this)
priv->reaper_init_done = _gf_true;
}
out:
- if (ret) {
- dict_unref (priv->xattrs);
+ if (ret && priv) {
+ if (priv->xattrs)
+ dict_unref (priv->xattrs);
+
GF_FREE (priv);
}