From: Daniel Mrzyglod Date: Thu, 18 Dec 2014 09:45:05 +0000 (+0000) Subject: af_packet: fix memory allocation checks X-Git-Tag: spdx-start~9894 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=74ab022182e82faeb89fc99d8ce3e1c4be7f776e;p=dpdk.git af_packet: fix memory allocation checks In rte_eth_af_packet.c we are we are missing NULL pointer checks after calls to allocate memory for queues. Add checking NULL pointer and error handling. Signed-off-by: Daniel Mrzyglod Acked-by: Neil Horman --- diff --git a/lib/librte_pmd_af_packet/rte_eth_af_packet.c b/lib/librte_pmd_af_packet/rte_eth_af_packet.c index ad7242cd6d..236749b988 100644 --- a/lib/librte_pmd_af_packet/rte_eth_af_packet.c +++ b/lib/librte_pmd_af_packet/rte_eth_af_packet.c @@ -603,6 +603,8 @@ rte_pmd_init_internals(const char *name, rdsize = req->tp_frame_nr * sizeof(*(rx_queue->rd)); rx_queue->rd = rte_zmalloc_socket(name, rdsize, 0, numa_node); + if (rx_queue->rd == NULL) + goto error; for (i = 0; i < req->tp_frame_nr; ++i) { rx_queue->rd[i].iov_base = rx_queue->map + (i * framesize); rx_queue->rd[i].iov_len = req->tp_frame_size; @@ -615,6 +617,8 @@ rte_pmd_init_internals(const char *name, tx_queue->map = rx_queue->map + req->tp_block_size * req->tp_block_nr; tx_queue->rd = rte_zmalloc_socket(name, rdsize, 0, numa_node); + if (tx_queue->rd == NULL) + goto error; for (i = 0; i < req->tp_frame_nr; ++i) { tx_queue->rd[i].iov_base = tx_queue->map + (i * framesize); tx_queue->rd[i].iov_len = req->tp_frame_size;