if (daemonize) {
if (daemon(0, 0) < 0) {
err("daemonizing failed: %s", strerror(errno));
+ usbip_host_driver_close();
return -1;
}
umask(0);
set_signal();
ai_head = do_getaddrinfo(NULL, PF_UNSPEC);
- if (!ai_head)
+ if (!ai_head) {
+ usbip_host_driver_close();
return -1;
+ }
info("starting " PROGNAME " (%s)", usbip_version_string);
nsockfd = listen_all_addrinfo(ai_head, sockfdlist);
if (nsockfd <= 0) {
err("failed to open a listening socket");
+ freeaddrinfo(ai_head);
+ usbip_host_driver_close();
return -1;
}
fds = calloc(nsockfd, sizeof(struct pollfd));