From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 0C8A31B461; Mon, 14 Jan 2019 04:37:53 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jan 2019 19:37:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,476,1539673200"; d="scan'208";a="109633056" Received: from dpdk-tbie.sh.intel.com ([10.67.104.173]) by orsmga008.jf.intel.com with ESMTP; 13 Jan 2019 19:37:52 -0800 From: Tiwei Bie To: maxime.coquelin@redhat.com, zhihong.wang@intel.com, dev@dpdk.org Cc: stable@dpdk.org Date: Mon, 14 Jan 2019 11:34:44 +0800 Message-Id: <20190114033444.13026-3-tiwei.bie@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190114033444.13026-1-tiwei.bie@intel.com> References: <20190114033444.13026-1-tiwei.bie@intel.com> Subject: [dpdk-stable] [PATCH 2/2] examples/vhost: fix realloc failure X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Jan 2019 03:37:54 -0000 Fixes: ad0eef4d2203 ("examples/vhost: support multiple socket files") Cc: stable@dpdk.org Signed-off-by: Tiwei Bie --- 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