summaryrefslogtreecommitdiff
path: root/drivers/staging/usbip
diff options
context:
space:
mode:
authorStefan Reif <ke42caxa@cip.cs.fau.de>2013-04-04 16:03:12 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-04-05 14:22:51 -0700
commite697949944c1427816e3cd01f8316040d7bddc57 (patch)
treea911f8997c579a267fa2b6e13ec435fd66575579 /drivers/staging/usbip
parentb94b3a627f415b17f5451e2cd607164655f30491 (diff)
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>
Diffstat (limited to 'drivers/staging/usbip')
-rw-r--r--drivers/staging/usbip/userspace/src/usbip_network.c4
-rw-r--r--drivers/staging/usbip/userspace/src/usbipd.c7
2 files changed, 8 insertions, 3 deletions
diff --git a/drivers/staging/usbip/userspace/src/usbip_network.c b/drivers/staging/usbip/userspace/src/usbip_network.c
index 4cb76e5d71c8..b12448ec69ab 100644
--- a/drivers/staging/usbip/userspace/src/usbip_network.c
+++ b/drivers/staging/usbip/userspace/src/usbip_network.c
@@ -248,10 +248,10 @@ int usbip_net_tcp_connect(char *hostname, char *service)
close(sockfd);
}
+ freeaddrinfo(res);
+
if (!rp)
return EAI_SYSTEM;
- freeaddrinfo(res);
-
return sockfd;
}
diff --git a/drivers/staging/usbip/userspace/src/usbipd.c b/drivers/staging/usbip/userspace/src/usbipd.c
index cc3be17b9e24..3f10c5183ffc 100644
--- a/drivers/staging/usbip/userspace/src/usbipd.c
+++ b/drivers/staging/usbip/userspace/src/usbipd.c
@@ -448,6 +448,7 @@ static int do_standalone_mode(int daemonize)
if (daemonize) {
if (daemon(0, 0) < 0) {
err("daemonizing failed: %s", strerror(errno));
+ usbip_host_driver_close();
return -1;
}
umask(0);
@@ -456,14 +457,18 @@ static int do_standalone_mode(int daemonize)
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));