Whamcloud - gitweb
LU-8022 lnet: Don't access NULL NI on failure path 14/19614/4
authorDoug Oucharek <doug.s.oucharek@intel.com>
Fri, 15 Apr 2016 18:37:54 +0000 (11:37 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 31 May 2016 04:54:21 +0000 (04:54 +0000)
In kiblnd_passive_connect(), if we are failing the connection
attempt because we cannot find a valid NI (we have a NULL NI),
we were coring after the "goto fail" because the failure
path was assuming non-NULL NI.

This patch ensures we don't dereference a NULL NI on that
failure path.

Signed-off-by: Doug Oucharek <doug.s.oucharek@intel.com>
Change-Id: I4f3deb78b4d3e9d81551ba915ceee852ec3b0792
Reviewed-on: http://review.whamcloud.com/19614
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Matt Ezell <ezellma@ornl.gov>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lnet/klnds/o2iblnd/o2iblnd_cb.c

index 1dbd518..4ff2e98 100644 (file)
@@ -2513,12 +2513,14 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob)
         return 0;
 
  failed:
-        if (ni != NULL)
-                lnet_ni_decref(ni);
+       if (ni != NULL) {
+               lnet_ni_decref(ni);
+               rej.ibr_cp.ibcp_queue_depth =
+                       kiblnd_msg_queue_size(version, ni);
+               rej.ibr_cp.ibcp_max_frags   = kiblnd_rdma_frags(version, ni);
+       }
 
        rej.ibr_version = version;
-       rej.ibr_cp.ibcp_queue_depth = kiblnd_msg_queue_size(version, ni);
-       rej.ibr_cp.ibcp_max_frags   = kiblnd_rdma_frags(version, ni);
        kiblnd_reject(cmid, &rej);
 
        return -ECONNREFUSED;