From dee1c932df22ee12fe4568b40e58a475309e62fd Mon Sep 17 00:00:00 2001 From: karthik-us Date: Thu, 7 Oct 2021 21:18:49 +0530 Subject: [PATCH 604/610] Coverity: Fix dereference before null check (CID: 1391415) Problem: In function gf_client_dump_inodes_to_dict() there is a null check for a variable which is already dereferenced in the previous line. This means that there could be a chance that this variable is null. But it is not being validate for null before dereferencing it in the first place. Fix: Added null check before dereferencing the variable at the first place. > Upstream patch: https://github.com/gluster/glusterfs/pull/2369/ > Change-Id: I988b0e93542782353a8059e33db1522b6a5e55f8 > Signed-off-by: karthik-us > Updates: gluster#1060 BUG: 1997447 Change-Id: I988b0e93542782353a8059e33db1522b6a5e55f8 Signed-off-by: karthik-us Reviewed-on: https://code.engineering.redhat.com/gerrit/c/rhs-glusterfs/+/280103 Tested-by: RHGS Build Bot Reviewed-by: Sunil Kumar Heggodu Gopala Acharya --- libglusterfs/src/client_t.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libglusterfs/src/client_t.c b/libglusterfs/src/client_t.c index e875c8b..216900a 100644 --- a/libglusterfs/src/client_t.c +++ b/libglusterfs/src/client_t.c @@ -828,8 +828,9 @@ gf_client_dump_inodes_to_dict(xlator_t *this, dict_t *dict) clienttable->cliententries[count].next_free) continue; client = clienttable->cliententries[count].client; - if (!strcmp(client->bound_xl->name, this->name)) { - if (client->bound_xl && client->bound_xl->itable) { + if (client->bound_xl && + !strcmp(client->bound_xl->name, this->name)) { + if (client->bound_xl->itable) { /* Presently every brick contains only * one bound_xl for all connections. * This will lead to duplicating of -- 1.8.3.1