From: jan Date: Fri, 12 Jul 2024 14:34:08 +0000 (+0000) Subject: vmd(8): Fix error handling in tx path. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c01d0122dff749fe566fdc2eed29fb00cf541be0;p=openbsd vmd(8): Fix error handling in tx path. ok dv@ --- 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++;