diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-01-11 03:06:20 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-01-11 03:06:20 +0000 |
commit | 2983f86d385326c8838db8e90fdd4a08d85bd054 (patch) | |
tree | 7a279a87b7245c7584e3d55d4b25054b1b07eb13 /sys/dev/pci/if_ix.c | |
parent | e83e53d88bf55a4d4c2c6e87ca33b8340f57e2d9 (diff) |
mallocarray() for the rx_buffer memory
Diffstat (limited to 'sys/dev/pci/if_ix.c')
-rw-r--r-- | sys/dev/pci/if_ix.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/dev/pci/if_ix.c b/sys/dev/pci/if_ix.c index cf1539c1a42..a69d6e4a63c 100644 --- a/sys/dev/pci/if_ix.c +++ b/sys/dev/pci/if_ix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ix.c,v 1.113 2014/12/22 02:28:52 tedu Exp $ */ +/* $OpenBSD: if_ix.c,v 1.114 2015/01/11 03:06:19 deraadt Exp $ */ /****************************************************************************** @@ -230,7 +230,7 @@ ixgbe_attach(struct device *parent, struct device *self, void *aux) goto err_out; /* Allocate multicast array memory. */ - sc->mta = malloc(sizeof(uint8_t) * IXGBE_ETH_LENGTH_OF_ADDRESS * + sc->mta = mallocarray(IXGBE_ETH_LENGTH_OF_ADDRESS, MAX_NUM_MULTICAST_ADDRESSES, M_DEVBUF, M_NOWAIT); if (sc->mta == NULL) { printf(": Can not allocate multicast setup array\n"); @@ -2475,13 +2475,14 @@ ixgbe_allocate_receive_buffers(struct rx_ring *rxr) int i, bsize, error; bsize = sizeof(struct ixgbe_rx_buf) * sc->num_rx_desc; - if (!(rxr->rx_buffers = (struct ixgbe_rx_buf *) malloc(bsize, - M_DEVBUF, M_NOWAIT | M_ZERO))) { + if (!(rxr->rx_buffers = mallocarray(sc->num_rx_desc, + sizeof(struct ixgbe_rx_buf), M_DEVBUF, M_NOWAIT | M_ZERO))) { printf("%s: Unable to allocate rx_buffer memory\n", ifp->if_xname); error = ENOMEM; goto fail; } + bsize = sizeof(struct ixgbe_rx_buf) * sc->num_rx_desc; rxbuf = rxr->rx_buffers; for (i = 0; i < sc->num_rx_desc; i++, rxbuf++) { |