From 8ea895389a92dbd08fb398dbda0a8f0f2dde063b Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Thu, 4 Jun 2020 08:57:31 +1000 Subject: [PATCH] LU-10391 lnet: fix uninitialize var in choose_ipv4_src() choose_ip4_src() test "*ret" without initializing it - and callers do not (and should not) initialize the var. Instead of testing "*ret", test "err" - if this is non-zero (it will be -ENOENT) we want to use the address. If it is zero, then we only use the address if it is on the right subnet. Test-Parameters: trivial Reported-by: Amir Shehata Fixes: d720fbaadad9 ("LU-10391 socklnd: use interface index to track local addr") Signed-off-by: Mr NeilBrown Change-Id: I9b83207b790db07c06be1ee1c534a0fc63eb9ffa Reviewed-on: https://review.whamcloud.com/38823 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Aurelien Degremont Reviewed-by: James Simmons Reviewed-by: Amir Shehata Reviewed-by: Oleg Drokin --- lnet/lnet/lib-socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lnet/lnet/lib-socket.c b/lnet/lnet/lib-socket.c index a3628da..ee4127c 100644 --- a/lnet/lnet/lib-socket.c +++ b/lnet/lnet/lib-socket.c @@ -163,7 +163,7 @@ int choose_ipv4_src(__u32 *ret, int interface, __u32 dst_ipaddr, struct net *ns) goto out; err = -ENOENT; in_dev_for_each_ifa_rcu(ifa, in_dev) { - if (*ret == 0 || + if (err || ((dst_ipaddr ^ ntohl(ifa->ifa_local)) & ntohl(ifa->ifa_mask)) == 0) { /* This address at least as good as what we -- 1.8.3.1