[dpdk-dev] af_packet: fix memory allocation check

Message ID 1418899870-18588-1-git-send-email-danielx.t.mrzyglod@intel.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Daniel Mrzyglod Dec. 18, 2014, 10:51 a.m. UTC
  In rte_eth_af_packet.c we are we are missing NULL pointer
checks after calls to alocate memory for queues. Add checking NULL
pointer and error handling.

Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
---
 lib/librte_pmd_af_packet/rte_eth_af_packet.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Thomas Monjalon Dec. 18, 2014, 8:58 p.m. UTC | #1
2014-12-18 10:51, Daniel Mrzyglod:
> In rte_eth_af_packet.c we are we are missing NULL pointer
> checks after calls to alocate memory for queues. Add checking NULL
> pointer and error handling.
> 
> Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>

You sent this patch twice:
	http://dpdk.org/ml/archives/dev/2014-December/010331.html
	http://dpdk.org/ml/archives/dev/2014-December/010333.html

And you didn't send any patch for the part "Not munmaped queue area"
of your original patch:
	http://dpdk.org/ml/archives/dev/2014-December/010229.html
  

Patch

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 ad7242c..236749b 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;