From: Tiwei Bie <tiwei.bie@intel.com>
To: maxime.coquelin@redhat.com, zhihong.wang@intel.com, dev@dpdk.org
Cc: stable@dpdk.org
Subject: [dpdk-dev] [PATCH 2/2] examples/vhost: fix realloc failure
Date: Mon, 14 Jan 2019 11:34:44 +0800 [thread overview]
Message-ID: <20190114033444.13026-3-tiwei.bie@intel.com> (raw)
In-Reply-To: <20190114033444.13026-1-tiwei.bie@intel.com>
Fixes: ad0eef4d2203 ("examples/vhost: support multiple socket files")
Cc: stable@dpdk.org
Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
---
examples/vhost/main.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index dc9ea1018..23fee445a 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -375,11 +375,19 @@ port_init(uint16_t port)
static int
us_vhost_parse_socket_path(const char *q_arg)
{
+ char *old;
+
/* parse number string */
if (strnlen(q_arg, PATH_MAX) == PATH_MAX)
return -1;
+ old = socket_files;
socket_files = realloc(socket_files, PATH_MAX * (nb_sockets + 1));
+ if (socket_files == NULL) {
+ free(old);
+ return -1;
+ }
+
snprintf(socket_files + nb_sockets * PATH_MAX, PATH_MAX, "%s", q_arg);
nb_sockets++;
--
2.17.1
next prev parent reply other threads:[~2019-01-14 3:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-14 3:34 [dpdk-dev] [PATCH 0/2] Fixes for realloc() in vhost Tiwei Bie
2019-01-14 3:34 ` [dpdk-dev] [PATCH 1/2] vhost: fix memory leak on realloc failure Tiwei Bie
2019-01-14 10:20 ` Maxime Coquelin
2019-01-14 3:34 ` Tiwei Bie [this message]
2019-01-14 10:20 ` [dpdk-dev] [PATCH 2/2] examples/vhost: fix " Maxime Coquelin
2019-01-15 1:56 ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
2019-01-15 6:53 ` Tiwei Bie
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=20190114033444.13026-3-tiwei.bie@intel.com \
--to=tiwei.bie@intel.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
--cc=stable@dpdk.org \
--cc=zhihong.wang@intel.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).