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