From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 418AE1B7F4; Thu, 8 Feb 2018 18:04:48 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Feb 2018 09:04:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,479,1511856000"; d="scan'208";a="29232986" Received: from unknown (HELO Sent) ([10.103.102.131]) by fmsmga001.fm.intel.com with SMTP; 08 Feb 2018 09:04:39 -0800 Received: by Sent (sSMTP sendmail emulation); Thu, 08 Feb 2018 18:03:36 +0100 From: Tomasz Kulasek To: yliu@fridaylinux.org Cc: dev@dpdk.org, jianfeng.tan@intel.com, stable@dpdk.org, Pawel Wodkowski Date: Thu, 8 Feb 2018 18:03:22 +0100 Message-Id: <20180208170322.52568-1-tomaszx.kulasek@intel.com> X-Mailer: git-send-email 2.12.3 Subject: [dpdk-dev] [PATCH] vhost: fix check if cmsg is NULL X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Feb 2018 17:04:48 -0000 Fixes: 6a84c37e3975 ("net/virtio-user: add vhost-user adapter layer") Cc: jianfeng.tan@intel.com Cc: stable@dpdk.org Signed-off-by: Pawel Wodkowski Signed-off-by: Tomasz Kulasek --- 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 83befdced..8fd47a4d8 100644 --- a/lib/librte_vhost/socket.c +++ b/lib/librte_vhost/socket.c @@ -153,6 +153,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.14.1