Skip to content

Commit

Permalink
Add vhost-path safety check when adding a socket pair
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Heinrich Kuhn <[email protected]>
  • Loading branch information
liujin3 authored and Heinrich Kuhn committed Nov 23, 2021
1 parent d622f01 commit b5cca74
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions virtio_vhostuser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b5cca74

Please sign in to comment.