summaryrefslogtreecommitdiffstats
path: root/xlators/meta
diff options
context:
space:
mode:
authorSunny Kumar <sunkumar@redhat.com>2018-08-14 14:41:16 +0530
committerAmar Tumballi <amarts@redhat.com>2018-08-17 03:06:16 +0000
commitdb16111e9f948069fc89d6653b6bd92f31808e65 (patch)
tree7eac196f0bc8b1e6ce5300629cae52a2ee38544e /xlators/meta
parentd17cccd520700eea30a7ed8b49eaf26f34e37ac2 (diff)
meta : fix coverity in meta-helpers.c
This fixes CID 1214627 and 1257625. updates: bz#789278 Change-Id: I6eb1ccf7b498948d1c41ff830e65437ef818cd55 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
Diffstat (limited to 'xlators/meta')
-rw-r--r--xlators/meta/src/meta-helpers.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/xlators/meta/src/meta-helpers.c b/xlators/meta/src/meta-helpers.c
index e681af59bf7..bffbe737ebb 100644
--- a/xlators/meta/src/meta-helpers.c
+++ b/xlators/meta/src/meta-helpers.c
@@ -23,18 +23,18 @@ meta_fd_get (fd_t *fd, xlator_t *this)
LOCK (&fd->lock);
{
- __fd_ctx_get (fd, this, &value);
- if (!value) {
- meta_fd = GF_CALLOC (1, sizeof (*meta_fd),
- gf_meta_mt_fd_t);
- if (!meta_fd)
- goto unlock;
-
- value = (long) meta_fd;
- __fd_ctx_set (fd, this, value);
- }
-
- meta_fd = (void *) value;
+ if (__fd_ctx_get (fd, this, &value) < 0) {
+ if (!value) {
+ meta_fd = GF_CALLOC (1, sizeof (*meta_fd),
+ gf_meta_mt_fd_t);
+ if (!meta_fd)
+ goto unlock;
+ value = (long) meta_fd;
+ __fd_ctx_set (fd, this, value);
+ }
+ } else {
+ meta_fd = (void *)value;
+ }
}
unlock:
UNLOCK (&fd->lock);
@@ -53,7 +53,7 @@ meta_fd_release (fd_t *fd, xlator_t *this)
fd_ctx_get (fd, this, &value);
meta_fd = (void *) value;
- if (meta_fd->dirents) {
+ if (meta_fd && meta_fd->dirents) {
for (i = 0; i < meta_fd->size; i++)
GF_FREE ((void *)meta_fd->dirents[i].name);
GF_FREE (meta_fd->dirents);