mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-26 03:05:29 +07:00
staging: usbip: userspace: avoid memory leaks
Call freeaddrinfo when connect/listen fails. Call usbip_host_driver_close on error. Signed-off-by: Stefan Reif <ke42caxa@cip.cs.fau.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
b94b3a627f
commit
e697949944
@ -248,10 +248,10 @@ int usbip_net_tcp_connect(char *hostname, char *service)
|
|||||||
close(sockfd);
|
close(sockfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
freeaddrinfo(res);
|
||||||
|
|
||||||
if (!rp)
|
if (!rp)
|
||||||
return EAI_SYSTEM;
|
return EAI_SYSTEM;
|
||||||
|
|
||||||
freeaddrinfo(res);
|
|
||||||
|
|
||||||
return sockfd;
|
return sockfd;
|
||||||
}
|
}
|
||||||
|
@ -448,6 +448,7 @@ static int do_standalone_mode(int daemonize)
|
|||||||
if (daemonize) {
|
if (daemonize) {
|
||||||
if (daemon(0, 0) < 0) {
|
if (daemon(0, 0) < 0) {
|
||||||
err("daemonizing failed: %s", strerror(errno));
|
err("daemonizing failed: %s", strerror(errno));
|
||||||
|
usbip_host_driver_close();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
umask(0);
|
umask(0);
|
||||||
@ -456,14 +457,18 @@ static int do_standalone_mode(int daemonize)
|
|||||||
set_signal();
|
set_signal();
|
||||||
|
|
||||||
ai_head = do_getaddrinfo(NULL, PF_UNSPEC);
|
ai_head = do_getaddrinfo(NULL, PF_UNSPEC);
|
||||||
if (!ai_head)
|
if (!ai_head) {
|
||||||
|
usbip_host_driver_close();
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
info("starting " PROGNAME " (%s)", usbip_version_string);
|
info("starting " PROGNAME " (%s)", usbip_version_string);
|
||||||
|
|
||||||
nsockfd = listen_all_addrinfo(ai_head, sockfdlist);
|
nsockfd = listen_all_addrinfo(ai_head, sockfdlist);
|
||||||
if (nsockfd <= 0) {
|
if (nsockfd <= 0) {
|
||||||
err("failed to open a listening socket");
|
err("failed to open a listening socket");
|
||||||
|
freeaddrinfo(ai_head);
|
||||||
|
usbip_host_driver_close();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fds = calloc(nsockfd, sizeof(struct pollfd));
|
fds = calloc(nsockfd, sizeof(struct pollfd));
|
||||||
|
Loading…
Reference in New Issue
Block a user