[dpdk-dev] [PATCH] vhost: fix check if cmsg is NULL
Tan, Jianfeng
jianfeng.tan at intel.com
Fri Feb 9 02:51:37 CET 2018
Hi Tomasz,
> -----Original Message-----
> From: Kulasek, TomaszX
> Sent: Friday, February 9, 2018 1:03 AM
> To: yliu at fridaylinux.org
> Cc: dev at dpdk.org; Tan, Jianfeng; stable at dpdk.org; Wodkowski, PawelX
> Subject: [PATCH] vhost: fix check if cmsg is NULL
>
> Fixes: 6a84c37e3975 ("net/virtio-user: add vhost-user adapter layer")
Firstly, this fix line is incorrect. It shall be:
Fixes: 8f972312b8f4 ("vhost: support vhost-user")
> Cc: jianfeng.tan at intel.com
> Cc: stable at dpdk.org
>
> Signed-off-by: Pawel Wodkowski <pawelx.wodkowski at intel.com>
> Signed-off-by: Tomasz Kulasek <tomaszx.kulasek at intel.com>
> ---
> 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);
I suppose it will not return NULL as the control is defined as a variable-length array. But no harm to check it.
Thanks,
Jianfeng
> + 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
More information about the dev
mailing list