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