From: Tomasz Kulasek Date: Fri, 9 Feb 2018 17:05:00 +0000 (+0100) Subject: vhost: check cmsg not null X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=aa001111b002a05bf126c688d06146c092c0795a;p=dpdk.git 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 --- 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;