From: Tiwei Bie <tiwei.bie@intel.com>
To: dev@dpdk.org
Cc: bruce.richardson@intel.com, stable@dpdk.org
Subject: [PATCH 1/2] contigmem: free the allocated memory when error occurs
Date: Tue, 9 May 2017 08:47:06 +0000 [thread overview]
Message-ID: <20170509084707.29949-2-tiwei.bie@intel.com> (raw)
In-Reply-To: <20170509084707.29949-1-tiwei.bie@intel.com>
Fixes: 764bf26873b9 ("add FreeBSD support")
Cc: stable@dpdk.org
Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
---
lib/librte_eal/bsdapp/contigmem/contigmem.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/lib/librte_eal/bsdapp/contigmem/contigmem.c b/lib/librte_eal/bsdapp/contigmem/contigmem.c
index da971debe..03e3e8def 100644
--- a/lib/librte_eal/bsdapp/contigmem/contigmem.c
+++ b/lib/librte_eal/bsdapp/contigmem/contigmem.c
@@ -123,19 +123,21 @@ static int
contigmem_load()
{
char index_string[8], description[32];
- int i;
+ int i, error = 0;
if (contigmem_num_buffers > RTE_CONTIGMEM_MAX_NUM_BUFS) {
printf("%d buffers requested is greater than %d allowed\n",
contigmem_num_buffers, RTE_CONTIGMEM_MAX_NUM_BUFS);
- return EINVAL;
+ error = EINVAL;
+ goto error;
}
if (contigmem_buffer_size < PAGE_SIZE ||
(contigmem_buffer_size & (contigmem_buffer_size - 1)) != 0) {
printf("buffer size 0x%lx is not greater than PAGE_SIZE and "
"power of two\n", contigmem_buffer_size);
- return EINVAL;
+ error = EINVAL;
+ goto error;
}
for (i = 0; i < contigmem_num_buffers; i++) {
@@ -145,7 +147,8 @@ contigmem_load()
if (contigmem_buffers[i] == NULL) {
printf("contigmalloc failed for buffer %d\n", i);
- return ENOMEM;
+ error = ENOMEM;
+ goto error;
}
printf("%2u: virt=%p phys=%p\n", i, contigmem_buffers[i],
@@ -165,6 +168,14 @@ contigmem_load()
GID_WHEEL, 0600, "contigmem");
return 0;
+
+error:
+ for (i = 0; i < contigmem_num_buffers; i++)
+ if (contigmem_buffers[i] != NULL)
+ contigfree(contigmem_buffers[i], contigmem_buffer_size,
+ M_CONTIGMEM);
+
+ return error;
}
static int
--
2.12.1
next prev parent reply other threads:[~2017-05-09 8:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-09 8:47 [PATCH 0/2] Various fixes for contigmem Tiwei Bie
2017-05-09 8:47 ` Tiwei Bie [this message]
2017-05-09 8:47 ` [PATCH 2/2] contigmem: don't zero the pages during each mmap Tiwei Bie
2017-05-10 14:05 ` [PATCH 0/2] Various fixes for contigmem Richardson, Bruce
2017-05-11 1:03 ` Tiwei Bie
2017-05-22 9:03 ` [PATCH v2 " Tiwei Bie
2017-05-22 9:03 ` [PATCH v2 1/2] contigmem: free the allocated memory when error occurs Tiwei Bie
2017-05-22 9:03 ` [PATCH v2 2/2] contigmem: don't zero the pages during each mmap Tiwei Bie
2017-05-22 10:15 ` [dpdk-stable] " Shahaf Shuler
2017-06-04 5:53 ` [PATCH v3 0/2] Various fixes for contigmem Tiwei Bie
2017-06-04 5:53 ` [PATCH v3 1/2] contigmem: free the allocated memory when error occurs Tiwei Bie
2017-06-04 5:53 ` [PATCH v3 2/2] contigmem: don't zero the pages during each mmap Tiwei Bie
2017-07-03 23:33 ` [PATCH v3 0/2] Various fixes for contigmem 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=20170509084707.29949-2-tiwei.bie@intel.com \
--to=tiwei.bie@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=stable@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.