From b5cca743ec4b464c562c01315d3e2c4d62a29eaa Mon Sep 17 00:00:00 2001 From: Jin liu Date: Wed, 10 Nov 2021 10:14:51 +0200 Subject: [PATCH] Add vhost-path safety check when adding a socket pair If the vhost-path parameter is not passed while adding a socket pair, return immediately, otherwise this may causes a null pointer access fault. Signed-off-by: Jin Liu Signed-off-by: Heinrich Kuhn --- virtio_vhostuser.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/virtio_vhostuser.c b/virtio_vhostuser.c index 6c0cfa9..50affff 100644 --- a/virtio_vhostuser.c +++ b/virtio_vhostuser.c @@ -729,6 +729,11 @@ int virtio_add_sock_dev_pair(const char *vhost_path, dpdk_port_t port_id; #endif + if (!vhost_path) { + log_error("vhost-path has to be specified when adding a socket pair"); + return -1; + } + dev = num_slaves == 1 ? slave_dbdfs[0] : name; #if RTE_VERSION >= RTE_VERSION_NUM(16,7,0,0) if (rte_eth_dev_get_port_by_name(dev, &port_id) == 0) {