From: sf Date: Wed, 28 Aug 2024 12:40:22 +0000 (+0000) Subject: vio: Fix allocation sizes X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=cd07c7058b7da546345a7ea7bd4909842f92c4cb;p=openbsd vio: Fix allocation sizes For both rx and tx, we need an array of bus_dmamap_t and mbuf pointers each. This results in a size of (rxqsize + txqsize) * (sizeof(bus_dmamap_t) + sizeof(struct mbuf *)) The factor 2 before the sizeof(bus_dmamap_t) was too much and we allocated more than we needed. OK bluhm@ --- diff --git a/sys/dev/pv/if_vio.c b/sys/dev/pv/if_vio.c index ffc98ff7969..470331d1d92 100644 --- a/sys/dev/pv/if_vio.c +++ b/sys/dev/pv/if_vio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vio.c,v 1.50 2024/08/27 19:11:20 sf Exp $ */ +/* $OpenBSD: if_vio.c,v 1.51 2024/08/28 12:40:22 sf Exp $ */ /* * Copyright (c) 2012 Stefan Fritsch, Alexander Fiveg. @@ -465,14 +465,14 @@ vio_alloc_mem(struct vio_softc *sc) } sc->sc_arrays = mallocarray(rxqsize + txqsize, - 2 * sizeof(bus_dmamap_t) + sizeof(struct mbuf *), M_DEVBUF, + sizeof(bus_dmamap_t) + sizeof(struct mbuf *), M_DEVBUF, M_WAITOK | M_CANFAIL | M_ZERO); if (sc->sc_arrays == NULL) { printf("unable to allocate mem for dmamaps\n"); goto err_hdr; } allocsize = (rxqsize + txqsize) * - (2 * sizeof(bus_dmamap_t) + sizeof(struct mbuf *)); + (sizeof(bus_dmamap_t) + sizeof(struct mbuf *)); sc->sc_tx_dmamaps = sc->sc_arrays + rxqsize; sc->sc_rx_mbufs = (void*) (sc->sc_tx_dmamaps + txqsize);