]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: lustre: Fix possible NULL pointer dereference in lprocfs_status.c
authorDmitry Eremin <dmitry.eremin@intel.com>
Wed, 4 Nov 2015 18:40:01 +0000 (13:40 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 16 Nov 2015 04:02:47 +0000 (20:02 -0800)
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>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6507
Reviewed-on: http://review.whamcloud.com/14808
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c

index 2de3c1b6fa49f2081636fc3a7eb1e38a9b7748f2..dda5ad105f2e32489d13e113926d62c57c4349f9 100644 (file)
@@ -665,15 +665,18 @@ int lprocfs_rd_import(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));