summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorTiwei Bie <tiwei.bie@intel.com>2019-01-15 15:13:24 +0800
committerFerruh Yigit <ferruh.yigit@intel.com>2019-01-18 09:47:26 +0100
commitd79035b7dd6e599589552573b53c138f488dead3 (patch)
treeb721f67ab6172d956e0e18d72a0922f07a00568a /examples
parente1c0834f95597b1d5a889532281eb2fde6774ddd (diff)
downloaddpdk-next-eventdev-d79035b7dd6e599589552573b53c138f488dead3.zip
dpdk-next-eventdev-d79035b7dd6e599589552573b53c138f488dead3.tar.gz
dpdk-next-eventdev-d79035b7dd6e599589552573b53c138f488dead3.tar.xz
examples/vhost: fix path allocation failure handling
Add the missing failure handling for path allocation, as realloc() may fail. Fixes: ad0eef4d2203 ("examples/vhost: support multiple socket files") Cc: stable@dpdk.org Signed-off-by: Tiwei Bie <tiwei.bie@intel.com> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/vhost/main.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 645cf51..5e914f5 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -353,11 +353,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++;