@@ -1882,12 +1882,14 @@ netdev_get_addrs(const char dev[], struct in6_addr **paddr,
}
for (ifa = if_addr_list; ifa; ifa = ifa->ifa_next) {
- int family;
+ if (ifa->ifa_addr != NULL) {
+ int family;
- family = ifa->ifa_addr->sa_family;
- if (family == AF_INET || family == AF_INET6) {
- if (!strncmp(ifa->ifa_name, dev, IFNAMSIZ)) {
- cnt++;
+ family = ifa->ifa_addr->sa_family;
+ if (family == AF_INET || family == AF_INET6) {
+ if (!strncmp(ifa->ifa_name, dev, IFNAMSIZ)) {
+ cnt++;
+ }
}
}
}
@@ -1901,7 +1903,7 @@ netdev_get_addrs(const char dev[], struct in6_addr **paddr,
for (ifa = if_addr_list; ifa; ifa = ifa->ifa_next) {
int family;
- if (strncmp(ifa->ifa_name, dev, IFNAMSIZ)) {
+ if (strncmp(ifa->ifa_name, dev, IFNAMSIZ) || ifa->ifa_addr == NULL) {
continue;
}
Some point-to-point devices like TUN devices will not have an address, and while iterating over ifaddrs, its ifa_addr will be NULL. This patch fixes a crash when starting ovs-vswitchd on a system with such a device. Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com> Fixes: a8704b502785 ("tunneling: Handle multiple ip address for given device.") Cc: Pravin B Shelar <pshelar@ovn.org> --- lib/netdev.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)