lib/virtio: return error if CMSG_FIRSTHDR returns NULL
Fix issue: potential NULL pointer dereference Change-Id: I623096c49e7a75e66404666a2f502ba3209e3530 Signed-off-by: GangCao <gang.cao@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14330 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Dong Yi <dongx.yi@intel.com> Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
This commit is contained in:
parent
503835ee63
commit
b50af42b62
@ -58,6 +58,10 @@ vhost_user_write(int fd, void *buf, int len, int *fds, int fd_num)
|
|||||||
msgh.msg_control = control;
|
msgh.msg_control = control;
|
||||||
msgh.msg_controllen = sizeof(control);
|
msgh.msg_controllen = sizeof(control);
|
||||||
cmsg = CMSG_FIRSTHDR(&msgh);
|
cmsg = CMSG_FIRSTHDR(&msgh);
|
||||||
|
if (!cmsg) {
|
||||||
|
SPDK_WARNLOG("First HDR is NULL\n");
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
cmsg->cmsg_len = CMSG_LEN(fd_size);
|
cmsg->cmsg_len = CMSG_LEN(fd_size);
|
||||||
cmsg->cmsg_level = SOL_SOCKET;
|
cmsg->cmsg_level = SOL_SOCKET;
|
||||||
cmsg->cmsg_type = SCM_RIGHTS;
|
cmsg->cmsg_type = SCM_RIGHTS;
|
||||||
|
Loading…
Reference in New Issue
Block a user