DPDK patches and discussions
 help / color / mirror / Atom feed
From: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] af_packet: fix memory allocation check
Date: Thu, 18 Dec 2014 10:51:10 +0000	[thread overview]
Message-ID: <1418899870-18588-1-git-send-email-danielx.t.mrzyglod@intel.com> (raw)

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(+)

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;
-- 
2.1.0

             reply	other threads:[~2014-12-18 14:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-18 10:51 Daniel Mrzyglod [this message]
2014-12-18 20:58 ` Thomas Monjalon
  -- strict thread matches above, loose matches on Subject: below --
2014-12-18  9:45 Daniel Mrzyglod
2014-12-18 21:15 ` Neil Horman
2014-12-18 22:14   ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1418899870-18588-1-git-send-email-danielx.t.mrzyglod@intel.com \
    --to=danielx.t.mrzyglod@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).