From 87392e5ab2acc58d9547d02b8417a605f0f1f4fd Mon Sep 17 00:00:00 2001 From: AKSUM <51446624+AKSUMRUS@users.noreply.github.com> Date: Wed, 26 Jun 2024 18:00:49 +0300 Subject: [PATCH] executor/common_lunux.h/usbip_server_init: Close fd if can't find usb port If usb port for usbip server can't be found, fd of the server and client should be closed. If they don't closed, the number of open files will increase and may overflow the number of available open files for the process. Signed-off-by: Pavel Nikulshin --- executor/common_linux.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/executor/common_linux.h b/executor/common_linux.h index f00b6be90e2d..4c2817f7dd42 100644 --- a/executor/common_linux.h +++ b/executor/common_linux.h @@ -2051,6 +2051,9 @@ static long syz_usbip_server_init(volatile long a0) int available_port_num = __atomic_fetch_add(&port_alloc[usb3], 1, __ATOMIC_RELAXED); if (available_port_num > VHCI_HC_PORTS) { debug("syz_usbip_server_init : no more available port for : %d\n", available_port_num); + + close(client_fd); + close(server_fd); return -1; } @@ -2067,6 +2070,8 @@ static long syz_usbip_server_init(volatile long a0) sprintf(buffer, "%d %d %s %d", port_num, client_fd, "0", speed); write_file("/sys/devices/platform/vhci_hcd.0/attach", buffer); + + close(client_fd); return server_fd; }