vold: Fix devmapper/ptmx fd leak, and give asec unmount more time
Signed-off-by: San Mehat <san@google.com>
diff --git a/logwrapper.c b/logwrapper.c
index c96426f..afc6cdb 100644
--- a/logwrapper.c
+++ b/logwrapper.c
@@ -119,6 +119,7 @@
if (grantpt(parent_ptty) || unlockpt(parent_ptty) ||
((child_devname = (char*)ptsname(parent_ptty)) == 0)) {
LOG(LOG_ERROR, "logwrapper", "Problem with /dev/ptmx");
+ close(parent_ptty);
return -1;
}
@@ -127,6 +128,9 @@
LOG(LOG_ERROR, "logwrapper", "Failed to fork");
return -errno;
} else if (pid == 0) {
+ /*
+ * Child
+ */
child_ptty = open(child_devname, O_RDWR);
if (child_ptty < 0) {
LOG(LOG_ERROR, "logwrapper", "Problem with child ptty");
@@ -160,7 +164,12 @@
child(argc, argv);
} else {
- return parent(argv[0], parent_ptty);
+ /*
+ * Parent
+ */
+ int rc = parent(argv[0], parent_ptty);
+ close(parent_ptty);
+ return rc;
}
return 0;