From c01d0122dff749fe566fdc2eed29fb00cf541be0 Mon Sep 17 00:00:00 2001 From: jan Date: Fri, 12 Jul 2024 14:34:08 +0000 Subject: [PATCH] vmd(8): Fix error handling in tx path. ok dv@ --- usr.sbin/vmd/vionet.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/usr.sbin/vmd/vionet.c b/usr.sbin/vmd/vionet.c index 4e4e2d98b81..8a82e302221 100644 --- a/usr.sbin/vmd/vionet.c +++ b/usr.sbin/vmd/vionet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vionet.c,v 1.15 2024/07/09 18:49:05 jan Exp $ */ +/* $OpenBSD: vionet.c,v 1.16 2024/07/12 14:34:08 jan Exp $ */ /* * Copyright (c) 2023 Dave Voutila @@ -805,10 +805,8 @@ vionet_tx(struct virtio_dev *dev) } /* Check if we've got a minimum viable amount of data. */ - if (chain_len < VIONET_MIN_TXLEN) { - sz = chain_len; + if (chain_len < VIONET_MIN_TXLEN) goto drop; - } /* * Packet inspection for ethernet header (if using a "local" @@ -832,7 +830,6 @@ vionet_tx(struct virtio_dev *dev) log_warnx("%s: bad source address %s", __func__, ether_ntoa((struct ether_addr *) eh->ether_shost)); - sz = chain_len; goto drop; } } @@ -852,10 +849,10 @@ vionet_tx(struct virtio_dev *dev) log_warn("%s", __func__); goto reset; } - sz += sizeof(struct virtio_net_hdr); + chain_len += sizeof(struct virtio_net_hdr); drop: used->ring[used->idx & VIONET_QUEUE_MASK].id = hdr_idx; - used->ring[used->idx & VIONET_QUEUE_MASK].len = sz; + used->ring[used->idx & VIONET_QUEUE_MASK].len = chain_len; __sync_synchronize(); used->idx++; idx++; -- 2.20.1