From aa001111b002a05bf126c688d06146c092c0795a Mon Sep 17 00:00:00 2001 From: Tomasz Kulasek Date: Fri, 9 Feb 2018 18:05:00 +0100 Subject: [PATCH] vhost: check cmsg not null Fixes: 8f972312b8f4 ("vhost: support vhost-user") Cc: stable@dpdk.org Signed-off-by: Pawel Wodkowski Signed-off-by: Tomasz Kulasek Reviewed-by: Jianfeng Tan Reviewed-by: Maxime Coquelin --- lib/librte_vhost/socket.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c index 776336c2c0..6ba60f5dcd 100644 --- a/lib/librte_vhost/socket.c +++ b/lib/librte_vhost/socket.c @@ -159,6 +159,11 @@ send_fd_message(int sockfd, char *buf, int buflen, int *fds, int fd_num) msgh.msg_control = control; msgh.msg_controllen = sizeof(control); cmsg = CMSG_FIRSTHDR(&msgh); + if (cmsg == NULL) { + RTE_LOG(ERR, VHOST_CONFIG, "cmsg == NULL\n"); + errno = EINVAL; + return -1; + } cmsg->cmsg_len = CMSG_LEN(fdsize); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS; -- 2.20.1