diff options
| author | Nigel Babu <nigelb@redhat.com> | 2017-02-18 14:02:30 +0530 | 
|---|---|---|
| committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2017-02-23 07:14:33 -0500 | 
| commit | b584c068c6526853f82ccd2a406c3596d7d56be0 (patch) | |
| tree | 1286f0ae23df7c54a19261bbdecad55e19dfce43 | |
| parent | afe3a0d2869b706a3d5257f39d6acb9cbe856b87 (diff) | |
libglusterfs, dht, locks, glusterd: Coverity fixes
Fix up use after free bugs and dead code
Change-Id: I8f79ed6b5108926c1fac31c147b5ecba79d10785
BUG: 1424905
Signed-off-by: Nigel Babu <nigelb@redhat.com>
Reviewed-on: https://review.gluster.org/16666
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
| -rw-r--r-- | libglusterfs/src/syncop.c | 4 | ||||
| -rw-r--r-- | xlators/cluster/dht/src/dht-common.c | 4 | ||||
| -rw-r--r-- | xlators/features/locks/src/common.c | 1 | ||||
| -rw-r--r-- | xlators/features/locks/src/posix.c | 4 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.c | 22 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server.c | 5 | 
6 files changed, 10 insertions, 30 deletions
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c index 00a9b576269..7275f22b099 100644 --- a/libglusterfs/src/syncop.c +++ b/libglusterfs/src/syncop.c @@ -831,8 +831,10 @@ syncenv_new (size_t stacksize, int procmin, int procmax)                  newenv->procs++;          } -        if (ret != 0) +        if (ret != 0) {                  syncenv_destroy (newenv); +                newenv = NULL; +        }          return newenv;  } diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 6a061641fd0..c9889514762 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -2474,6 +2474,7 @@ dht_lookup (call_frame_t *frame, xlator_t *this,          dht_layout_t *layout = NULL;          int           i = 0;          int           call_cnt = 0; +        int           gen = 0;          loc_t         new_loc = {0,};          VALIDATE_OR_GOTO (frame, err); @@ -2548,6 +2549,7 @@ dht_lookup (call_frame_t *frame, xlator_t *this,                                        "incomplete layout failure for path=%s",                                        loc->path); +                        gen = layout->gen;                          dht_layout_unref (this, local->layout);                          local->layout = NULL;                          local->cached_subvol = NULL; @@ -2556,7 +2558,7 @@ dht_lookup (call_frame_t *frame, xlator_t *this,                                       "Called revalidate lookup for %s, "                                       "but layout->gen (%d) is less than "                                       "conf->gen (%d), calling fresh_lookup", -                                     loc->path, layout->gen, conf->gen); +                                     loc->path, gen, conf->gen);                          goto do_fresh_lookup;                  } diff --git a/xlators/features/locks/src/common.c b/xlators/features/locks/src/common.c index 796b538f6f2..8cdff0d61ef 100644 --- a/xlators/features/locks/src/common.c +++ b/xlators/features/locks/src/common.c @@ -480,6 +480,7 @@ new_posix_lock (struct gf_flock *flock, client_t *client, pid_t client_pid,          lock->client_uid = gf_strdup (client->client_uid);          if (lock->client_uid == NULL) {                  GF_FREE (lock); +                lock = NULL;                  goto out;          } diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c index 0e75ad889be..5d79fa16a66 100644 --- a/xlators/features/locks/src/posix.c +++ b/xlators/features/locks/src/posix.c @@ -2840,6 +2840,7 @@ new_meta_lock (call_frame_t *frame, xlator_t *this)                  gf_msg (this->name, GF_LOG_ERROR, 0, ENOMEM, "mem allocation"                          " failed for client_uid");                  GF_FREE (lock); +                lock = NULL;                  goto out;          } @@ -3808,7 +3809,8 @@ gf_lkmig_info_to_posix_lock (call_frame_t *frame,          lock->client_uid = gf_strdup (lmi->client_uid);          if (lock->client_uid == NULL) {                  GF_FREE (lock); -               goto out; +                lock = NULL; +                goto out;          }          lock->client_pid = lmi->flock.l_pid; diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index 059161470ae..73af41bde96 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -737,28 +737,6 @@ glusterd_check_localoption (char *key)  }  int -glusterd_check_voloption (char *key) -{ -        char *completion = NULL; -        struct volopt_map_entry *vmep = NULL; -        int ret = 0; - -        COMPLETE_OPTION(key, completion, ret); -        for (vmep = glusterd_volopt_map; vmep->key; vmep++) { -                if (strcmp (vmep->key, key) == 0) { -                        if ((vmep->type == DOC) || -                            (vmep->type == DOC)) -                                return _gf_true; -                        else -                                return _gf_false; -                } -        } - -        return _gf_false; - -} - -int  glusterd_check_option_exists (char *key, char **completion)  {          struct volopt_map_entry vme = {0,}; diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c index 4739c4560a6..202fe71ba55 100644 --- a/xlators/protocol/server/src/server.c +++ b/xlators/protocol/server/src/server.c @@ -132,11 +132,6 @@ gfs_serialize_reply (rpcsvc_request_t *req, void *arg, struct iovec *outmsg,          }          outmsg->iov_len = retlen;  ret: -        if (retlen == -1) { -                iobuf_unref (iob); -                iob = NULL; -        } -          return iob;  }  | 
