net: if: net_if_get_default: Return NULL if no interfaces configured
net_if_get_default() was documented as returning "Default interface or NULL if no interfaces are configured.", but actually didn't return NULL in the latter case. Instead, it effectively returned a pointer to random area of memory, shared with other system structures, so calling functions like net_if_ipv4_set_netmask(), etc. could trash unrelated memory. Jira: ZEP-2105 Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
This commit is contained in:
parent
72a30f3843
commit
e4a5e35b28
1 changed files with 4 additions and 0 deletions
|
@ -321,6 +321,10 @@ struct net_if *net_if_lookup_by_dev(struct device *dev)
|
||||||
|
|
||||||
struct net_if *net_if_get_default(void)
|
struct net_if *net_if_get_default(void)
|
||||||
{
|
{
|
||||||
|
if (__net_if_start == __net_if_end) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return __net_if_start;
|
return __net_if_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue