b51a1f
From f3db0c99faf813e0f2e9ffcf599416555a59df1f Mon Sep 17 00:00:00 2001
b51a1f
From: Ashish Pandey <aspandey@redhat.com>
b51a1f
Date: Tue, 9 Feb 2021 16:43:35 +0530
b51a1f
Subject: [PATCH 542/542] xlaotrs/mgmt: Fixing coverity issue 1445996
b51a1f
b51a1f
Backport of https://github.com/gluster/glusterfs/pull/2148/commits/9785e96e0bdf6e60896570fdf5e4a6976a6f60ba
b51a1f
b51a1f
Fixing "Null pointer dereferences"
b51a1f
b51a1f
BUG: 1927235
b51a1f
Change-Id: Idbc014e1302d2450f97bccd028681198c0d97424
b51a1f
Signed-off-by: Ashish Pandey <aspandey@redhat.com>
b51a1f
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
b51a1f
Reviewed-on: https://code.engineering.redhat.com/gerrit/237433
b51a1f
Tested-by: RHGS Build Bot <nigelb@redhat.com>
b51a1f
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
b51a1f
---
b51a1f
 xlators/mgmt/glusterd/src/glusterd-volgen.c | 12 +++++++-----
b51a1f
 1 file changed, 7 insertions(+), 5 deletions(-)
b51a1f
b51a1f
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
b51a1f
index a242b5c..71aed08 100644
b51a1f
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
b51a1f
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
b51a1f
@@ -2916,21 +2916,23 @@ validate_user_xlator_position(dict_t *this, char *key, data_t *value,
b51a1f
 {
b51a1f
     int ret = -1;
b51a1f
     int i = 0;
b51a1f
+    char *value_str = NULL;
b51a1f
 
b51a1f
     if (!value)
b51a1f
         goto out;
b51a1f
 
b51a1f
+    value_str = data_to_str(value);
b51a1f
+    if (!value_str)
b51a1f
+        goto out;
b51a1f
+
b51a1f
     if (fnmatch("user.xlator.*.*", key, 0) == 0) {
b51a1f
         ret = 0;
b51a1f
         goto out;
b51a1f
     }
b51a1f
 
b51a1f
-    char *value_str = data_to_str(value);
b51a1f
-    if (!value_str)
b51a1f
-        goto out;
b51a1f
-
b51a1f
     int num_xlators = sizeof(server_graph_table) /
b51a1f
                       sizeof(server_graph_table[0]);
b51a1f
+
b51a1f
     for (i = 0; i < num_xlators; i++) {
b51a1f
         if (server_graph_table[i].dbg_key &&
b51a1f
             strcmp(value_str, server_graph_table[i].dbg_key) == 0) {
b51a1f
@@ -2942,7 +2944,7 @@ validate_user_xlator_position(dict_t *this, char *key, data_t *value,
b51a1f
 out:
b51a1f
     if (ret == -1)
b51a1f
         gf_log("glusterd", GF_LOG_ERROR, "invalid user xlator position %s = %s",
b51a1f
-               key, value->data);
b51a1f
+               key, value_str);
b51a1f
 
b51a1f
     return ret;
b51a1f
 }
b51a1f
-- 
b51a1f
1.8.3.1
b51a1f