diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 4c58880f8c..13606cea44 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -1997,8 +1997,14 @@ read_vhost_message(int sockfd, struct VhostUserMsg *msg) ret = read_fd_message(sockfd, (char *)msg, VHOST_USER_HDR_SIZE, msg->fds, VHOST_MEMORY_MAX_NREGIONS, &msg->fd_num); - if (ret <= 0) + if (ret <= 0) { return ret; + } else if (ret != VHOST_USER_HDR_SIZE) { + RTE_LOG(ERR, VHOST_CONFIG, + "Unexpected header size read\n"); + close_msg_fds(msg); + return -1; + } if (msg->size) { if (msg->size > sizeof(msg->payload)) {