From: Filippo Storniolo Date: Fri, 3 Nov 2023 17:55:49 +0000 (+0100) Subject: test/vsock fix: add missing check on socket creation X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=bfada5a7672fea5465d81bba3d05fca6024a244e;p=linux.git 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 Signed-off-by: Luigi Leonardi Signed-off-by: Filippo Storniolo Reviewed-by: Stefano Garzarella Signed-off-by: David S. Miller --- diff --git a/tools/testing/vsock/util.c b/tools/testing/vsock/util.c index 92336721321af..698b0b44a2eea 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");