mirror of
https://github.com/torvalds/linux.git
synced 2026-09-25 21:21:09 -04:00
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 <[email protected]> Signed-off-by: Luigi Leonardi <[email protected]> Signed-off-by: Filippo Storniolo <[email protected]> Reviewed-by: Stefano Garzarella <[email protected]> Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
committed by
David S. Miller
parent
3a5cc90a4d
commit
bfada5a767
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user