Commit bfada5a7 authored by Filippo Storniolo's avatar Filippo Storniolo Committed by David S. Miller

test/vsock fix: add missing check on socket creation

Add check on socket() return value in vsock_listen()
and vsock_connect()
Co-developed-by: default avatarLuigi Leonardi <luigi.leonardi@outlook.com>
Signed-off-by: default avatarLuigi Leonardi <luigi.leonardi@outlook.com>
Signed-off-by: default avatarFilippo Storniolo <f.storniolo95@gmail.com>
Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3a5cc90a
......@@ -104,6 +104,10 @@ static int vsock_connect(unsigned int cid, unsigned int port, int type)
control_expectln("LISTENING");
fd = socket(AF_VSOCK, type, 0);
if (fd < 0) {
perror("socket");
exit(EXIT_FAILURE);
}
timeout_begin(TIMEOUT);
do {
......@@ -158,6 +162,10 @@ static int vsock_accept(unsigned int cid, unsigned int port,
int old_errno;
fd = socket(AF_VSOCK, type, 0);
if (fd < 0) {
perror("socket");
exit(EXIT_FAILURE);
}
if (bind(fd, &addr.sa, sizeof(addr.svm)) < 0) {
perror("bind");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment