diff options
author | arao <arao@redhat.com> | 2015-02-17 16:53:14 +0530 |
---|---|---|
committer | Raghavendra G <rgowdapp@redhat.com> | 2015-05-08 01:22:35 -0700 |
commit | 1a9df097463d41679b87b6cbd4634fc3390fe82c (patch) | |
tree | 6b01fdaa2a6cde01c151c190ebf835f9bc246b8a | |
parent | 9dcb6e07cf432a047654a3f04a23a438fe969bfb (diff) |
dht: Fixing dereference after null check
CID: 1223229
The 'loc' ptr is not checked before
dereferencing, which is handled.
Change-Id: Icf668150bde190e6f1b9f58a038099338516efe8
BUG: 789278
Signed-off-by: arao <arao@redhat.com>
Reviewed-on: http://review.gluster.org/9666
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Tested-by: Raghavendra G <rgowdapp@redhat.com>
-rw-r--r-- | xlators/cluster/dht/src/dht-layout.c | 51 |
1 files changed, 38 insertions, 13 deletions
diff --git a/xlators/cluster/dht/src/dht-layout.c b/xlators/cluster/dht/src/dht-layout.c index 2ed15c5e43c..6ef28472307 100644 --- a/xlators/cluster/dht/src/dht-layout.c +++ b/xlators/cluster/dht/src/dht-layout.c @@ -745,9 +745,12 @@ dht_layout_dir_mismatch (xlator_t *this, dht_layout_t *layout, xlator_t *subvol, } if (pos == -1) { - gf_msg_debug (this->name, 0, - "%s - no layout info for subvolume %s", - loc->path, subvol->name); + if (loc) { + gf_msg_debug (this->name, 0, + "%s - no layout info for subvolume %s", + loc ? loc->path : "path not found", + subvol->name); + } ret = 1; goto out; } @@ -756,9 +759,15 @@ dht_layout_dir_mismatch (xlator_t *this, dht_layout_t *layout, xlator_t *subvol, if (!xattr) { if (err == 0) { - gf_log (this->name, GF_LOG_INFO, - "%s: xattr dictionary is NULL", - loc->path); + if (loc) { + gf_log (this->name, GF_LOG_INFO, + "%s: xattr dictionary is NULL", + loc->path); + } else { + gf_log (this->name, GF_LOG_INFO, + "path not found: " + "xattr dictionary is NULL"); + } ret = -1; } goto out; @@ -769,9 +778,16 @@ dht_layout_dir_mismatch (xlator_t *this, dht_layout_t *layout, xlator_t *subvol, if (dict_ret < 0) { if (err == 0 && layout->list[pos].stop) { - gf_log (this->name, GF_LOG_INFO, - "%s: Disk layout missing, gfid = %s", - loc->path, gfid); + if (loc) { + gf_log (this->name, GF_LOG_INFO, + "%s: Disk layout missing, gfid = %s", + loc->path, gfid); + } else { + gf_log (this->name, GF_LOG_INFO, + "path not found: " + "Disk layout missing, gfid = %s", + gfid); + } ret = -1; } goto out; @@ -781,10 +797,19 @@ dht_layout_dir_mismatch (xlator_t *this, dht_layout_t *layout, xlator_t *subvol, count = ntoh32 (disk_layout[0]); if (count != 1) { - gf_msg (this->name, GF_LOG_ERROR, 0, - DHT_MSG_INVALID_DISK_LAYOUT, - "Invalid disk layout: invalid count %d," - "path = %s, gfid = %s ", count, loc->path, gfid); + if (loc) { + gf_msg (this->name, GF_LOG_ERROR, 0, + DHT_MSG_INVALID_DISK_LAYOUT, + "Invalid disk layout: invalid count %d," + "path = %s, gfid = %s ", + count, loc->path, gfid); + } else { + gf_msg (this->name, GF_LOG_ERROR, 0, + DHT_MSG_INVALID_DISK_LAYOUT, + "Invalid disk layout: invalid count %d," + "path not found, gfid = %s ", + count, gfid); + } ret = -1; goto out; } |