diff options
| author | Pedro F. Giffuni <pfg@FreeBSD.org> | 2018-01-13 22:30:30 +0000 |
|---|---|---|
| committer | Pedro F. Giffuni <pfg@FreeBSD.org> | 2018-01-13 22:30:30 +0000 |
| commit | 26c1d774b55c4db79bca772941883244986e6f44 (patch) | |
| tree | 0d4a99e9eba470c0808a66d7d3f857c9f36446fa /sys/dev/virtio | |
| parent | a019e26c0f76f5fd5c401cd87554ef2d5efc36ca (diff) | |
Notes
Diffstat (limited to 'sys/dev/virtio')
| -rw-r--r-- | sys/dev/virtio/console/virtio_console.c | 10 | ||||
| -rw-r--r-- | sys/dev/virtio/mmio/virtio_mmio.c | 2 | ||||
| -rw-r--r-- | sys/dev/virtio/network/if_vtnet.c | 7 | ||||
| -rw-r--r-- | sys/dev/virtio/pci/virtio_pci.c | 4 |
4 files changed, 13 insertions, 10 deletions
diff --git a/sys/dev/virtio/console/virtio_console.c b/sys/dev/virtio/console/virtio_console.c index 919e61be90f7..00b605b633b1 100644 --- a/sys/dev/virtio/console/virtio_console.c +++ b/sys/dev/virtio/console/virtio_console.c @@ -474,11 +474,11 @@ static int vtcon_alloc_scports(struct vtcon_softc *sc) { struct vtcon_softc_port *scport; - int max, i; + u_int max, i; max = sc->vtcon_max_ports; - sc->vtcon_ports = malloc(sizeof(struct vtcon_softc_port) * max, + sc->vtcon_ports = mallocarray(max, sizeof(struct vtcon_softc_port), M_DEVBUF, M_NOWAIT | M_ZERO); if (sc->vtcon_ports == NULL) return (ENOMEM); @@ -497,7 +497,8 @@ vtcon_alloc_virtqueues(struct vtcon_softc *sc) device_t dev; struct vq_alloc_info *info; struct vtcon_softc_port *scport; - int i, idx, portidx, nvqs, error; + u_int i, idx, portidx, nvqs; + int error; dev = sc->vtcon_dev; @@ -505,7 +506,8 @@ vtcon_alloc_virtqueues(struct vtcon_softc *sc) if (sc->vtcon_flags & VTCON_FLAG_MULTIPORT) nvqs += 2; - info = malloc(sizeof(struct vq_alloc_info) * nvqs, M_TEMP, M_NOWAIT); + info = mallocarray(nvqs, sizeof(struct vq_alloc_info), M_TEMP, + M_NOWAIT); if (info == NULL) return (ENOMEM); diff --git a/sys/dev/virtio/mmio/virtio_mmio.c b/sys/dev/virtio/mmio/virtio_mmio.c index d9c17f5e8421..52d392574c95 100644 --- a/sys/dev/virtio/mmio/virtio_mmio.c +++ b/sys/dev/virtio/mmio/virtio_mmio.c @@ -507,7 +507,7 @@ vtmmio_alloc_virtqueues(device_t dev, int flags, int nvqs, if (nvqs <= 0) return (EINVAL); - sc->vtmmio_vqs = malloc(nvqs * sizeof(struct vtmmio_virtqueue), + sc->vtmmio_vqs = mallocarray(nvqs, sizeof(struct vtmmio_virtqueue), M_DEVBUF, M_NOWAIT | M_ZERO); if (sc->vtmmio_vqs == NULL) return (ENOMEM); diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c index 2a7174177d56..fe1b99eddf69 100644 --- a/sys/dev/virtio/network/if_vtnet.c +++ b/sys/dev/virtio/network/if_vtnet.c @@ -755,9 +755,9 @@ vtnet_alloc_rxtx_queues(struct vtnet_softc *sc) npairs = sc->vtnet_max_vq_pairs; - sc->vtnet_rxqs = malloc(sizeof(struct vtnet_rxq) * npairs, M_DEVBUF, + sc->vtnet_rxqs = mallocarray(npairs, sizeof(struct vtnet_rxq), M_DEVBUF, M_NOWAIT | M_ZERO); - sc->vtnet_txqs = malloc(sizeof(struct vtnet_txq) * npairs, M_DEVBUF, + sc->vtnet_txqs = mallocarray(npairs, sizeof(struct vtnet_txq), M_DEVBUF, M_NOWAIT | M_ZERO); if (sc->vtnet_rxqs == NULL || sc->vtnet_txqs == NULL) return (ENOMEM); @@ -887,7 +887,8 @@ vtnet_alloc_virtqueues(struct vtnet_softc *sc) if (sc->vtnet_flags & VTNET_FLAG_CTRL_VQ) nvqs++; - info = malloc(sizeof(struct vq_alloc_info) * nvqs, M_TEMP, M_NOWAIT); + info = mallocarray(nvqs, sizeof(struct vq_alloc_info), M_TEMP, + M_NOWAIT); if (info == NULL) return (ENOMEM); diff --git a/sys/dev/virtio/pci/virtio_pci.c b/sys/dev/virtio/pci/virtio_pci.c index 100b44cd1843..f5964996bcfd 100644 --- a/sys/dev/virtio/pci/virtio_pci.c +++ b/sys/dev/virtio/pci/virtio_pci.c @@ -491,7 +491,7 @@ vtpci_alloc_virtqueues(device_t dev, int flags, int nvqs, if (nvqs <= 0) return (EINVAL); - sc->vtpci_vqs = malloc(nvqs * sizeof(struct vtpci_virtqueue), + sc->vtpci_vqs = mallocarray(nvqs, sizeof(struct vtpci_virtqueue), M_DEVBUF, M_NOWAIT | M_ZERO); if (sc->vtpci_vqs == NULL) return (ENOMEM); @@ -927,7 +927,7 @@ vtpci_alloc_intr_resources(struct vtpci_softc *sc) /* Subtract one for the configuration changed interrupt. */ nvq_intrs = sc->vtpci_nmsix_resources - 1; - intr = sc->vtpci_msix_vq_interrupts = malloc(nvq_intrs * + intr = sc->vtpci_msix_vq_interrupts = mallocarray(nvq_intrs, sizeof(struct vtpci_interrupt), M_DEVBUF, M_NOWAIT | M_ZERO); if (sc->vtpci_msix_vq_interrupts == NULL) return (ENOMEM); |
