staging/lustre/lnet: fix potential null pointer dereference in kiblnd_rejected
authorDmitry Eremin <dmitry.eremin@intel.com>
Mon, 28 Apr 2014 02:25:57 +0000 (22:25 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 3 May 2014 23:35:21 +0000 (19:35 -0400)
Null pointer 'cp' that comes from line 2544 may be dereferenced
at line 2618.
found by Klocwork Insight tool

Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-on: http://review.whamcloud.com/9386
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4629
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Isaac Huang <he.huang@intel.com>
Signed-off-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c

index 6173e74d7492b1e121abf1c37792d5bb71c03718..9bf6c949f5db671b33bdf7bafbda3f79228d802f 100644 (file)
@@ -2609,13 +2609,17 @@ kiblnd_rejected (kib_conn_t *conn, int reason, void *priv, int priv_nob)
 
                        case IBLND_REJECT_MSG_QUEUE_SIZE:
                                CERROR("%s rejected: incompatible message queue depth %d, %d\n",
-                                      libcfs_nid2str(peer->ibp_nid), cp->ibcp_queue_depth,
+                                      libcfs_nid2str(peer->ibp_nid),
+                                      cp != NULL ? cp->ibcp_queue_depth :
+                                      IBLND_MSG_QUEUE_SIZE(rej->ibr_version),
                                       IBLND_MSG_QUEUE_SIZE(conn->ibc_version));
                                break;
 
                        case IBLND_REJECT_RDMA_FRAGS:
                                CERROR("%s rejected: incompatible # of RDMA fragments %d, %d\n",
-                                      libcfs_nid2str(peer->ibp_nid), cp->ibcp_max_frags,
+                                      libcfs_nid2str(peer->ibp_nid),
+                                      cp != NULL ? cp->ibcp_max_frags :
+                                      IBLND_RDMA_FRAGS(rej->ibr_version),
                                       IBLND_RDMA_FRAGS(conn->ibc_version));
                                break;