DPDK patches and discussions
 help / color / mirror / Atom feed
From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: dariusz.stojaczyk@intel.com, gavin.hu@arm.com
Subject: [dpdk-dev] [PATCH] fbarray: fix init unlock without lock
Date: Fri, 29 Mar 2019 10:57:08 +0000	[thread overview]
Message-ID: <35fe9a105fbf7868fc34cef330745b33acd0527c.1553856703.git.anatoly.burakov@intel.com> (raw)
Message-ID: <20190329105708.Ngn0MSi63XLtyoHUjCDfwncCvqleGFV-YBHlWnzOS2Q@z> (raw)

Certain failure paths of rte_fbarray_init() will unlock the
mem area lock without locking it first. Fix this by properly
handling the failures.

Fixes: 5b61c62cfd76 ("fbarray: add internal tailq for mapped areas")

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_common_fbarray.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_fbarray.c b/lib/librte_eal/common/eal_common_fbarray.c
index 0e7366e5e..f852c7f50 100644
--- a/lib/librte_eal/common/eal_common_fbarray.c
+++ b/lib/librte_eal/common/eal_common_fbarray.c
@@ -736,15 +736,19 @@ rte_fbarray_init(struct rte_fbarray *arr, const char *name, unsigned int len,
 	}
 
 	page_sz = sysconf(_SC_PAGESIZE);
-	if (page_sz == (size_t)-1)
-		goto fail;
+	if (page_sz == (size_t)-1) {
+		free(ma);
+		return -1;
+	}
 
 	/* calculate our memory limits */
 	mmap_len = calc_data_size(page_sz, elt_sz, len);
 
 	data = eal_get_virtual_area(NULL, &mmap_len, page_sz, 0, 0);
-	if (data == NULL)
-		goto fail;
+	if (data == NULL) {
+		free(ma);
+		return -1;
+	}
 
 	rte_spinlock_lock(&mem_area_lock);
 
-- 
2.17.1

             reply	other threads:[~2019-03-29 10:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-29 10:57 Anatoly Burakov [this message]
2019-03-29 10:57 ` Anatoly Burakov
2019-03-29 11:50 ` Thomas Monjalon
2019-03-29 11:50   ` 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=35fe9a105fbf7868fc34cef330745b33acd0527c.1553856703.git.anatoly.burakov@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=dariusz.stojaczyk@intel.com \
    --cc=dev@dpdk.org \
    --cc=gavin.hu@arm.com \
    /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).