aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzhar Shaikh <azhars@codeaurora.org>2015-04-16 11:52:48 -0700
committerMoyster <oysterized@gmail.com>2016-09-13 13:23:01 +0200
commit7e66a533ba6ef95027bed0cc77b11881fd0fb1e0 (patch)
tree68c01c59e2245ec1a6e51df6e291e2d203af4ca3
parent4e48f1b500af46a1907e7b337439d0f21a11deac (diff)
USB: android: Fix memory leak in mass_storage_function_init()
mass_storage_function_init() calls fsg_common_init() which allocates memory to fsg buffers only once during bootup. This memory is never freed, which results in a memory leak. The reference count is incremented in mass_storage_function_init() and in fsg_bind_config(). The count incremented in bind_config is decremented in fsg_unbind(). Free this memory and also decrement the reference count in mass_storage_function_cleanup() which will be called during gadget unbind. Change-Id: I51e8d062471540df01bcb3122195711bbaffe455 Signed-off-by: Azhar Shaikh <azhars@codeaurora.org>
-rw-r--r--drivers/usb/gadget/android.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/usb/gadget/android.c b/drivers/usb/gadget/android.c
index 83add822b..ac016b13e 100644
--- a/drivers/usb/gadget/android.c
+++ b/drivers/usb/gadget/android.c
@@ -1550,6 +1550,10 @@ static int mass_storage_function_init(struct android_usb_function *f,
static void mass_storage_function_cleanup(struct android_usb_function *f)
{
+ struct mass_storage_function_config *config;
+
+ config = f->config;
+ fsg_common_put(config->common);
kfree(f->config);
f->config = NULL;
}