Skip to content
Permalink
Browse files

net: if: Fix null pointer deref when selecting IPv4 address

It is possible that iface is NULL when selecting IPv4 destination
address for a sent packet.

Coverity-CID: 198877
Fixes #16570

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
  • Loading branch information...
jukkar authored and nashif committed Jun 7, 2019
1 parent ada05ea commit 343bdd3e3ac2793c2aa85f71bafc4b3a3471967e
Showing with 6 additions and 1 deletion.
  1. +6 −1 subsys/net/ip/net_if.c
@@ -2336,9 +2336,14 @@ static struct in_addr *net_if_ipv4_get_best_match(struct net_if *iface,
static struct in_addr *if_ipv4_get_addr(struct net_if *iface,
enum net_addr_state addr_state, bool ll)
{
struct net_if_ipv4 *ipv4 = iface->config.ip.ipv4;
struct net_if_ipv4 *ipv4;
int i;

if (!iface) {
return NULL;
}

ipv4 = iface->config.ip.ipv4;
if (!ipv4) {
return NULL;
}

0 comments on commit 343bdd3

Please sign in to comment.
You can’t perform that action at this time.