Fix fd leaks
When you open a file, you should remember to close it.
bug:2639464
Change-Id: I90d25dba2a262b620373270832eb3189616c720d
diff --git a/UsbController.cpp b/UsbController.cpp
index 0c1fb58..1def0e6 100644
--- a/UsbController.cpp
+++ b/UsbController.cpp
@@ -49,6 +49,7 @@
int fd = open("/sys/class/usb_composite/rndis/enable", O_RDWR);
int count = snprintf(value, sizeof(value), "%d\n", (enable ? 1 : 0));
write(fd, value, count);
+ close(fd);
return 0;
}
@@ -56,5 +57,6 @@
char value=0;
int fd = open("/sys/class/usb_composite/rndis/enable", O_RDWR);
read(fd, &value, 1);
+ close(fd);
return (value == '1' ? true : false);
}