From d47f00d5a420b594b49564b2e00efca4602c3fb5 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Thu, 14 May 2015 18:52:06 +0300 Subject: [PATCH] LU-6507 obdclass: Fix possible NULL pointer dereference 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 Change-Id: I16212eb6eb195eb197683606a4e4709810ff708f Reviewed-on: http://review.whamcloud.com/14808 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Bob Glossman Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- lustre/obdclass/lprocfs_status.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 02764bd..c8ce66c 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -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, "", 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 ? "" : nidstr, + nidstr, imp->imp_conn_cnt, imp->imp_generation, atomic_read(&imp->imp_inval_count)); -- 1.8.3.1