diff --git a/net/ipfrag/ipv4_frag.c b/net/ipfrag/ipv4_frag.c index 66091c5c8cf..b3f82329136 100644 --- a/net/ipfrag/ipv4_frag.c +++ b/net/ipfrag/ipv4_frag.c @@ -361,7 +361,7 @@ int32_t ipv4_fragout(FAR struct net_driver_s *dev, uint16_t mtu) uint32_t nfrags; uint16_t offset = 0; uint16_t hdrlen; - FAR struct iob_s *frag; + FAR struct iob_s *frag = NULL; FAR struct ipv4_hdr_s *ref = NULL; struct iob_queue_s fragq = { @@ -379,9 +379,15 @@ int32_t ipv4_fragout(FAR struct net_driver_s *dev, uint16_t mtu) */ nfrags = ip_fragout_slice(dev->d_iob, PF_INET, mtu, hdrlen, &fragq); - ASSERT(nfrags > 1); netdev_iob_clear(dev); + /* No I/O Buffer is the only cause of failure */ + + if (nfrags == 0) + { + goto fail; + } + /* Fill the L3 header into the reserved space */ for (iter = 0; iter < nfrags; iter++) diff --git a/net/ipfrag/ipv6_frag.c b/net/ipfrag/ipv6_frag.c index 3fdb4c845bb..69b09580d69 100644 --- a/net/ipfrag/ipv6_frag.c +++ b/net/ipfrag/ipv6_frag.c @@ -570,7 +570,7 @@ int32_t ipv6_fragout(FAR struct net_driver_s *dev, uint16_t mtu) uint32_t nfrags; uint16_t hdroff; uint16_t hdrtype; - FAR struct iob_s *frag; + FAR struct iob_s *frag = NULL; FAR struct ipv6_hdr_s *ref = NULL; FAR struct ipv6_fragment_extension_s *fraghdr; struct iob_queue_s fragq = @@ -590,9 +590,15 @@ int32_t ipv6_fragout(FAR struct net_driver_s *dev, uint16_t mtu) */ nfrags = ip_fragout_slice(dev->d_iob, PF_INET6, mtu, unfraglen, &fragq); - ASSERT(nfrags > 1); netdev_iob_clear(dev); + /* No I/O Buffer is the only cause of failure */ + + if (nfrags == 0) + { + goto fail; + } + ipid = ++g_ipv6id; /* Fill the L3 header into the reserved space */