summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorFilippo Storniolo <f.storniolo95@gmail.com>2023-11-03 18:55:49 +0100
committerDavid S. Miller <davem@davemloft.net>2023-11-07 23:27:07 +0100
commitbfada5a7672fea5465d81bba3d05fca6024a244e (patch)
tree18f72231b52795917779e17dc05b4ab10370d7f2 /tools
parentvsock/virtio: remove socket from connected/bound list on shutdown (diff)
downloadlinux-bfada5a7672fea5465d81bba3d05fca6024a244e.tar.xz
linux-bfada5a7672fea5465d81bba3d05fca6024a244e.zip
test/vsock fix: add missing check on socket creation
Add check on socket() return value in vsock_listen() and vsock_connect() Co-developed-by: Luigi Leonardi <luigi.leonardi@outlook.com> Signed-off-by: Luigi Leonardi <luigi.leonardi@outlook.com> Signed-off-by: Filippo Storniolo <f.storniolo95@gmail.com> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/vsock/util.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/testing/vsock/util.c b/tools/testing/vsock/util.c
index 92336721321a..698b0b44a2ee 100644
--- a/tools/testing/vsock/util.c
+++ b/tools/testing/vsock/util.c
@@ -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");