net: if: Check iface before setting/getting interface MTU
Do not try to set or get the interface MTU if the interface pointer is NULL. Coverity-CID: 220541 Fixes #34000 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
d4b9620dda
commit
b7c63d43f2
1 changed files with 8 additions and 0 deletions
|
@ -782,6 +782,10 @@ static inline int net_if_set_link_addr(struct net_if *iface,
|
|||
*/
|
||||
static inline uint16_t net_if_get_mtu(struct net_if *iface)
|
||||
{
|
||||
if (iface == NULL) {
|
||||
return 0U;
|
||||
}
|
||||
|
||||
return iface->if_dev->mtu;
|
||||
}
|
||||
|
||||
|
@ -794,6 +798,10 @@ static inline uint16_t net_if_get_mtu(struct net_if *iface)
|
|||
static inline void net_if_set_mtu(struct net_if *iface,
|
||||
uint16_t mtu)
|
||||
{
|
||||
if (iface == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
iface->if_dev->mtu = mtu;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue