Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F161707636
D13833.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D13833.diff
View Options
Index: head/sys/dev/e1000/if_em.c
===================================================================
--- head/sys/dev/e1000/if_em.c
+++ head/sys/dev/e1000/if_em.c
@@ -2835,9 +2835,9 @@
/* First allocate the top level queue structs */
if (!(adapter->tx_queues =
- (struct em_tx_queue *) malloc(sizeof(struct em_tx_queue) *
- adapter->tx_num_queues, M_DEVBUF, M_NOWAIT | M_ZERO))) {
- device_printf(iflib_get_dev(ctx), "Unable to allocate queue memory\n");
+ (struct em_tx_queue *) mallocarray(adapter->tx_num_queues,
+ sizeof(struct em_tx_queue), M_DEVBUF, M_NOWAIT | M_ZERO))) {
+ device_printf(iflib_get_dev(ctx), "Unable to allocate queue memory\n");
return(ENOMEM);
}
@@ -2849,7 +2849,8 @@
que->me = txr->me = i;
/* Allocate report status array */
- if (!(txr->tx_rsq = (qidx_t *) malloc(sizeof(qidx_t) * scctx->isc_ntxd[0], M_DEVBUF, M_NOWAIT | M_ZERO))) {
+ if (!(txr->tx_rsq = (qidx_t *) mallocarray(scctx->isc_ntxd[0],
+ sizeof(qidx_t), M_DEVBUF, M_NOWAIT | M_ZERO))) {
device_printf(iflib_get_dev(ctx), "failed to allocate rs_idxs memory\n");
error = ENOMEM;
goto fail;
@@ -2881,8 +2882,8 @@
/* First allocate the top level queue structs */
if (!(adapter->rx_queues =
- (struct em_rx_queue *) malloc(sizeof(struct em_rx_queue) *
- adapter->rx_num_queues, M_DEVBUF, M_NOWAIT | M_ZERO))) {
+ (struct em_rx_queue *) mallocarray(adapter->rx_num_queues,
+ sizeof(struct em_rx_queue), M_DEVBUF, M_NOWAIT | M_ZERO))) {
device_printf(iflib_get_dev(ctx), "Unable to allocate queue memory\n");
error = ENOMEM;
goto fail;
Index: head/sys/dev/ixl/if_ixlv.c
===================================================================
--- head/sys/dev/ixl/if_ixlv.c
+++ head/sys/dev/ixl/if_ixlv.c
@@ -1637,8 +1637,8 @@
/* Get memory for the station queues */
if (!(vsi->queues =
- (struct ixl_queue *) malloc(sizeof(struct ixl_queue) *
- vsi->num_queues, M_DEVBUF, M_NOWAIT | M_ZERO))) {
+ (struct ixl_queue *) mallocarray(vsi->num_queues,
+ sizeof(struct ixl_queue), M_DEVBUF, M_NOWAIT | M_ZERO))) {
device_printf(dev, "Unable to allocate queue memory\n");
error = ENOMEM;
goto early;
Index: head/sys/dev/ixl/ixl_pf_iov.c
===================================================================
--- head/sys/dev/ixl/ixl_pf_iov.c
+++ head/sys/dev/ixl/ixl_pf_iov.c
@@ -1695,8 +1695,8 @@
pf_vsi = &pf->vsi;
IXL_PF_LOCK(pf);
- pf->vfs = malloc(sizeof(struct ixl_vf) * num_vfs, M_IXL, M_NOWAIT |
- M_ZERO);
+ pf->vfs = mallocarray(num_vfs, sizeof(struct ixl_vf), M_IXL,
+ M_NOWAIT | M_ZERO);
if (pf->vfs == NULL) {
error = ENOMEM;
Index: head/sys/dev/ixl/ixl_pf_main.c
===================================================================
--- head/sys/dev/ixl/ixl_pf_main.c
+++ head/sys/dev/ixl/ixl_pf_main.c
@@ -2431,8 +2431,8 @@
/* Get memory for the station queues */
if (!(vsi->queues =
- (struct ixl_queue *) malloc(sizeof(struct ixl_queue) *
- vsi->num_queues, M_DEVBUF, M_NOWAIT | M_ZERO))) {
+ (struct ixl_queue *) mallocarray(vsi->num_queues,
+ sizeof(struct ixl_queue), M_DEVBUF, M_NOWAIT | M_ZERO))) {
device_printf(dev, "Unable to allocate queue memory\n");
error = ENOMEM;
return (error);
@@ -3317,7 +3317,7 @@
hw = &pf->hw;
IXL_PF_LOCK_ASSERT(pf);
- a = malloc(sizeof(struct i40e_aqc_add_macvlan_element_data) * cnt,
+ a = mallocarray(cnt, sizeof(struct i40e_aqc_add_macvlan_element_data),
M_DEVBUF, M_NOWAIT | M_ZERO);
if (a == NULL) {
device_printf(dev, "add_hw_filters failed to get memory\n");
@@ -3380,7 +3380,8 @@
hw = &pf->hw;
dev = pf->dev;
- d = malloc(sizeof(struct i40e_aqc_remove_macvlan_element_data) * cnt,
+ d = mallocarray(cnt,
+ sizeof(struct i40e_aqc_remove_macvlan_element_data),
M_DEVBUF, M_NOWAIT | M_ZERO);
if (d == NULL) {
printf("del hw filter failed to get memory\n");
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jul 7, 3:31 AM (17 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34749036
Default Alt Text
D13833.diff (3 KB)
Attached To
Mode
D13833: Make use of the newly introduce mallocarray(9).
Attached
Detach File
Event Timeline
Log In to Comment