Whamcloud - gitweb
LU-6507 obdclass: Fix possible NULL pointer dereference 08/14808/4
authorDmitry Eremin <dmitry.eremin@intel.com>
Thu, 14 May 2015 15:52:06 +0000 (18:52 +0300)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 28 May 2015 22:15:22 +0000 (22:15 +0000)
The imp->imp_connection really could be NULL, we better check for it
before dereferencing it in taht call to libcfs_nid2str_r.

Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Change-Id: I16212eb6eb195eb197683606a4e4709810ff708f
Reviewed-on: http://review.whamcloud.com/14808
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/obdclass/lprocfs_status.c

index 02764bd..c8ce66c 100644 (file)
@@ -789,14 +789,17 @@ int lprocfs_import_seq_show(struct seq_file *m, void *data)
                seq_printf(m, "%s%s", j ? ", " : "", nidstr);
                j++;
        }
-       libcfs_nid2str_r(imp->imp_connection->c_peer.nid,
-                        nidstr, sizeof(nidstr));
+       if (imp->imp_connection != NULL)
+               libcfs_nid2str_r(imp->imp_connection->c_peer.nid,
+                                nidstr, sizeof(nidstr));
+       else
+               strncpy(nidstr, "<none>", sizeof(nidstr));
        seq_printf(m, " ]\n"
                      "       current_connection: %s\n"
                      "       connection_attempts: %u\n"
                      "       generation: %u\n"
                      "       in-progress_invalidations: %u\n",
-                     imp->imp_connection == NULL ? "<none>" : nidstr,
+                     nidstr,
                      imp->imp_conn_cnt,
                      imp->imp_generation,
                      atomic_read(&imp->imp_inval_count));