Found with clang static analysis: lib/librte_vhost/virtio_net.c:723:17: warning: Access to field 'data_off' results in a dereference of a null pointer (loaded from variable 'tcp_hdr') m->l4_len = (tcp_hdr->data_off & 0xf0) >> 2; ^~~~~~~~~~~~~~~~~
Fixes: 2a51b1091cb5 ("vhost: support indirect descriptor in non-mergeable Rx") Signed-off-by: Emmanuel Roullit <emmanuel.roul...@gmail.com> --- lib/librte_vhost/virtio_net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index 595f67c4d..82444b7b9 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -677,6 +677,7 @@ parse_ethernet(struct rte_mbuf *m, uint16_t *l4_proto, void **l4_hdr) default: m->l3_len = 0; *l4_proto = 0; + *l4_hdr = NULL; break; } } @@ -713,7 +714,7 @@ vhost_dequeue_offload(struct virtio_net_hdr *hdr, struct rte_mbuf *m) } } - if (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) { + if (l4_hdr && hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) { switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) { case VIRTIO_NET_HDR_GSO_TCPV4: case VIRTIO_NET_HDR_GSO_TCPV6: -- 2.11.0