diff options
author | Iraj Jamali <ijamali@redhat.com> | 2018-09-24 16:44:45 +0530 |
---|---|---|
committer | Atin Mukherjee <amukherj@redhat.com> | 2018-10-03 11:58:18 +0000 |
commit | 0153fcfcbd0e442824ec9bc19122a253512e98ea (patch) | |
tree | 6af9079f08bda0947bc603e85ac3af09e3cdc0c7 /xlators/mgmt/glusterd/src/glusterd-brick-ops.c | |
parent | 04a98cd88e9e9eb9f7bc6c174671d82ece666fbf (diff) |
mgmt/glusterd: NULL pointer dereferencing clang fix
Added checks to avoid NULL pointer dereferencing
Updates: bz#1622665
Change-Id: I745c1f3ba4df0e486ce99301843f9f13d01c00e0
Signed-off-by: Iraj Jamali <ijamali@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-brick-ops.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c index 2698ef783af..8719bbf3fd6 100644 --- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c @@ -721,19 +721,20 @@ subvol_matcher_update(int *subvols, glusterd_volinfo_t *volinfo, glusterd_brickinfo_t *tmp = NULL; int32_t sub_volume = 0; int pos = 0; - - cds_list_for_each_entry(tmp, &volinfo->bricks, brick_list) - { - if (strcmp(tmp->hostname, brickinfo->hostname) || - strcmp(tmp->path, brickinfo->path)) { - pos++; - continue; + if (subvols) { + cds_list_for_each_entry(tmp, &volinfo->bricks, brick_list) + { + if (strcmp(tmp->hostname, brickinfo->hostname) || + strcmp(tmp->path, brickinfo->path)) { + pos++; + continue; + } + gf_msg_debug(THIS->name, 0, LOGSTR_FOUND_BRICK, brickinfo->hostname, + brickinfo->path, volinfo->volname); + sub_volume = (pos / volinfo->dist_leaf_count); + subvols[sub_volume]++; + break; } - gf_msg_debug(THIS->name, 0, LOGSTR_FOUND_BRICK, brickinfo->hostname, - brickinfo->path, volinfo->volname); - sub_volume = (pos / volinfo->dist_leaf_count); - subvols[sub_volume]++; - break; } } @@ -745,7 +746,7 @@ subvol_matcher_verify(int *subvols, glusterd_volinfo_t *volinfo, char *err_str, int ret = 0; int count = volinfo->replica_count - replica_count; - if (replica_count) { + if (replica_count && subvols) { for (i = 0; i < volinfo->subvol_count; i++) { if (subvols[i] != count) { ret = -1; @@ -760,7 +761,7 @@ subvol_matcher_verify(int *subvols, glusterd_volinfo_t *volinfo, char *err_str, } do { - if (subvols[i] % volinfo->dist_leaf_count == 0) { + if (subvols && (subvols[i] % volinfo->dist_leaf_count == 0)) { continue; } else { ret = -1; @@ -1244,7 +1245,7 @@ _glusterd_restart_gsync_session(dict_t *this, char *key, data_t *value, &slave_url, &slave_host, &slave_vol, &conf_path, errmsg); if (ret) { - if (*errmsg) + if (errmsg && *errmsg) gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_SLAVE_CONFPATH_DETAILS_FETCH_FAIL, "%s", *errmsg); else |