summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlokilee73 <changjoo.lee@samsung.com>2019-01-16 11:33:15 (GMT)
committerHyotaek Shim <hyotaek.shim@samsung.com>2019-01-17 11:08:07 (GMT)
commitf3e15a75312c01c9e56bec38766ab479f187f279 (patch)
treee9b580adde7883e7831c5dfbba6694b567549509
parente301e7b1ca4efecc3c3884f462207548fef5daf3 (diff)
downloadlibdevice-node-f3e15a75312c01c9e56bec38766ab479f187f279.zip
libdevice-node-f3e15a75312c01c9e56bec38766ab479f187f279.tar.gz
libdevice-node-f3e15a75312c01c9e56bec38766ab479f187f279.tar.bz2
Change-Id: I437409ae6c162ecd7dd4a7abf70a5290f12cda98 Signed-off-by: lokilee73 <changjoo.lee@samsung.com> Signed-off-by: Hyotaek Shim <hyotaek.shim@samsung.com>
-rw-r--r--hw/usb_client_common.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/hw/usb_client_common.c b/hw/usb_client_common.c
index 7a77dc4..50008ef 100644
--- a/hw/usb_client_common.c
+++ b/hw/usb_client_common.c
@@ -66,6 +66,8 @@
#define EXPORT __attribute__ ((visibility("default")))
#endif
+static void legacy_free_gadget(struct usb_gadget *gadget);
+
static int get_int_from_file(char *path, int *_val, int base)
{
char buf[INT_BUF_SIZE];
@@ -563,6 +565,7 @@ static int legacy_enable(struct usb_client *usb)
goto stop_services;
}
+ legacy_free_gadget(gadget);
return 0;
stop_services:
while (--i >= 0) {
@@ -574,6 +577,7 @@ stop_services:
struct usb_function_with_service, func);
systemd_stop_service(fws->service);
}
+ legacy_free_gadget(gadget);
disable_gadget:
sys_set_str(LEGACY_ENABLE_PATH, LEGACY_DISABLE);
@@ -598,10 +602,14 @@ static int legacy_disable(struct usb_client *usb)
fws = container_of(gadget->funcs[i], struct usb_function_with_service, func);
ret = systemd_stop_service(fws->service);
if (ret < 0)
- return ret;
+ goto free_gadget;
}
- return sys_set_str(LEGACY_ENABLE_PATH, LEGACY_DISABLE);
+ ret = sys_set_str(LEGACY_ENABLE_PATH, LEGACY_DISABLE);
+
+free_gadget:
+ legacy_free_gadget(gadget);
+ return ret;
}
static void legacy_free_config(struct usb_configuration *config)
@@ -657,6 +665,8 @@ static void legacy_free_gadget(struct usb_gadget *gadget)
free(gadget->funcs);
}
+
+ free(gadget);
}
EXPORT