Whamcloud - gitweb
LU-10391 lnet: fix uninitialize var in choose_ipv4_src() 23/38823/2
authorMr NeilBrown <neilb@suse.de>
Wed, 3 Jun 2020 22:57:31 +0000 (08:57 +1000)
committerOleg Drokin <green@whamcloud.com>
Wed, 10 Jun 2020 20:51:28 +0000 (20:51 +0000)
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 <ashehata@whamcloud.com>
Fixes: d720fbaadad9 ("LU-10391 socklnd: use interface index to track local addr")
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I9b83207b790db07c06be1ee1c534a0fc63eb9ffa
Reviewed-on: https://review.whamcloud.com/38823
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Aurelien Degremont <degremoa@amazon.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Amir Shehata <ashehata@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>

index a3628da..ee4127c 100644 (file)
@@ -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