From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 1/3] af_packet: ensure *internals is not null when dereferencing
Date: Tue, 16 Dec 2014 16:30:22 +0000 [thread overview]
Message-ID: <1418747424-22254-2-git-send-email-bruce.richardson@intel.com> (raw)
In-Reply-To: <1418747424-22254-1-git-send-email-bruce.richardson@intel.com>
The cleanup code on error checks for *internals being NULL only after
using the pointer to perform other cleanup. Fix this by moving the
clean-up based on the pointer inside the check for NULL.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
lib/librte_pmd_af_packet/rte_eth_af_packet.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
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 d0fb3eb..ad7242c 100644
--- a/lib/librte_pmd_af_packet/rte_eth_af_packet.c
+++ b/lib/librte_pmd_af_packet/rte_eth_af_packet.c
@@ -676,14 +676,15 @@ error:
rte_free(data);
if (pci_dev)
rte_free(pci_dev);
- for (q = 0; q < nb_queues; q++) {
- if ((*internals)->rx_queue[q].rd)
- rte_free((*internals)->rx_queue[q].rd);
- if ((*internals)->tx_queue[q].rd)
- rte_free((*internals)->tx_queue[q].rd);
- }
- if (*internals)
+ if (*internals) {
+ for (q = 0; q < nb_queues; q++) {
+ if ((*internals)->rx_queue[q].rd)
+ rte_free((*internals)->rx_queue[q].rd);
+ if ((*internals)->tx_queue[q].rd)
+ rte_free((*internals)->tx_queue[q].rd);
+ }
rte_free(*internals);
+ }
return -1;
}
--
1.9.3
next prev parent reply other threads:[~2014-12-16 16:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-16 16:30 [dpdk-dev] [PATCH 0/3] (More) Fixes for issues highlighted by static analysis Bruce Richardson
2014-12-16 16:30 ` Bruce Richardson [this message]
2014-12-16 16:30 ` [dpdk-dev] [PATCH 2/3] ixgbe: prevent array overflow access in vector driver Bruce Richardson
2014-12-16 16:30 ` [dpdk-dev] [PATCH 3/3] eal: for safety, use snprintf instead of sprintf Bruce Richardson
2014-12-16 23:52 ` [dpdk-dev] [PATCH 0/3] (More) Fixes for issues highlighted by static analysis 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=1418747424-22254-2-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).