Structure device not freed in error case
In case of an error in the call usb_device_get_fd()
the memory created by usb_open_device() is never
freed.
Added a call to usb_device_close in case of error to
release the allocated memory.
Change-Id: Iaa83674f000242d80604dd30c782236f7afd90c2
diff --git a/services/jni/com_android_server_UsbHostManager.cpp b/services/jni/com_android_server_UsbHostManager.cpp
index f1fa6cf..fc6de60 100644
--- a/services/jni/com_android_server_UsbHostManager.cpp
+++ b/services/jni/com_android_server_UsbHostManager.cpp
@@ -163,8 +163,10 @@
return NULL;
int fd = usb_device_get_fd(device);
- if (fd < 0)
+ if (fd < 0) {
+ usb_device_close(device);
return NULL;
+ }
int newFD = dup(fd);
usb_device_close(device);