staging: lustre: fix socklnd issues found by Klocwork Insight tool
authorDmitry Eremin <dmitry.eremin@intel.com>
Wed, 2 Mar 2016 22:01:55 +0000 (17:01 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 2 Mar 2016 23:23:49 +0000 (15:23 -0800)
Null pointer 'best_iface' that comes from line 802 may be
dereferenced at line 832.

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

index 2c83b95002ae437cb61931d246844c995cbd4ce1..a710541f0b7ffa4b5f1a735d9330d962e2f0b2f8 100644 (file)
@@ -804,6 +804,8 @@ ksocknal_select_ips(ksock_peer_t *peer, __u32 *peerips, int n_peerips)
                        ip = peer->ksnp_passive_ips[i];
                        best_iface = ksocknal_ip2iface(peer->ksnp_ni, ip);
 
+                       /* peer passive ips are kept up to date */
+                       LASSERT(best_iface);
                } else {
                        /* choose a new interface */
                        LASSERT(i == peer->ksnp_n_passive_ips);
@@ -838,6 +840,8 @@ ksocknal_select_ips(ksock_peer_t *peer, __u32 *peerips, int n_peerips)
                                best_npeers = iface->ksni_npeers;
                        }
 
+                       LASSERT(best_iface);
+
                        best_iface->ksni_npeers++;
                        ip = best_iface->ksni_ipaddr;
                        peer->ksnp_passive_ips[i] = ip;