DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 2/5] test: check for mbuf alloc failure
Date: Tue, 16 Dec 2014 15:03:50 +0000	[thread overview]
Message-ID: <1418742233-16776-3-git-send-email-bruce.richardson@intel.com> (raw)
In-Reply-To: <1418742233-16776-1-git-send-email-bruce.richardson@intel.com>

If mbuf allocation failed for whatever reason, we would get a NULL
pointer exception in test_table_acl.c:test_pipeline_single_filter test
case.
We fix this by causing an early break out of the application loop. If we
quit the test immediately we would leak any existing allocated mbufs,
but by breaking instead, we allow the test to continue and clean up the
mbufs already in the pipeline, while still having a test failure as the
mbuf counts should not match.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 app/test/test_table_acl.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/app/test/test_table_acl.c b/app/test/test_table_acl.c
index 0f2b57e..e4e9b9c 100644
--- a/app/test/test_table_acl.c
+++ b/app/test/test_table_acl.c
@@ -513,6 +513,11 @@ test_pipeline_single_filter(int expected_count)
 			struct rte_mbuf *mbuf;
 
 			mbuf = rte_pktmbuf_alloc(pool);
+			if (mbuf == NULL)
+				/* this will cause test failure after cleanup
+				 * of already enqueued mbufs, as the mbuf
+				 * counts won't match */
+				break;
 			memset(rte_pktmbuf_mtod(mbuf, char *), 0x00,
 				sizeof(struct ipv4_5tuple));
 
-- 
1.9.3

  parent reply	other threads:[~2014-12-16 15:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-16 15:03 [dpdk-dev] [PATCH 0/5] Fixes for issues highlighted by static analysis scan Bruce Richardson
2014-12-16 15:03 ` [dpdk-dev] [PATCH 1/5] test: after NULL check, don't free the NULL pointer Bruce Richardson
2014-12-16 15:03 ` Bruce Richardson [this message]
2014-12-16 15:03 ` [dpdk-dev] [PATCH 3/5] examples: set correct limit for length of unix socket path Bruce Richardson
2014-12-16 15:03 ` [dpdk-dev] [PATCH 4/5] examples: fix check for null before de-reference Bruce Richardson
2014-12-16 15:03 ` [dpdk-dev] [PATCH 5/5] cfgfile: prevent error when reading an empty file Bruce Richardson
2014-12-16 23:53 ` [dpdk-dev] [PATCH 0/5] Fixes for issues highlighted by static analysis scan 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=1418742233-16776-3-git-send-email-bruce.richardson@intel.com \
    --to=bruce.richardson@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).