aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Brauner <christian.brauner@ubuntu.com>2017-08-21 16:13:28 +0200
committerMartijn Coenen <maco@android.com>2018-07-17 11:14:23 +0200
commit558ee9362338560772b003407a8440a08ce72899 (patch)
tree11f0ca17f5197e1cd9f9321dbeef0ddb2f0dc386
parentfbb4339c024d65c9eadbfc664d82bf8c5307ac18 (diff)
downloadlinux-linaro-stable-558ee9362338560772b003407a8440a08ce72899.tar.gz
UPSTREAM: binder: free memory on error
On binder_init() the devices string is duplicated and smashed into individual device names which are passed along. However, the original duplicated string wasn't freed in case binder_init() failed. Let's free it on error. Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit 22eb9476b5d80a393ac0ba235c42bccc90b82c76) Change-Id: I78fdeecf70c31ba4248b3de17130f97546288f84
-rw-r--r--drivers/android/binder.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 3d49fd1e391c..e85ba20d2994 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -5796,7 +5796,7 @@ static int __init init_binder_device(const char *name)
static int __init binder_init(void)
{
int ret;
- char *device_name, *device_names;
+ char *device_name, *device_names, *device_tmp;
struct binder_device *device;
struct hlist_node *tmp;
@@ -5851,7 +5851,8 @@ static int __init binder_init(void)
}
strcpy(device_names, binder_devices_param);
- while ((device_name = strsep(&device_names, ","))) {
+ device_tmp = device_names;
+ while ((device_name = strsep(&device_tmp, ","))) {
ret = init_binder_device(device_name);
if (ret)
goto err_init_binder_device_failed;
@@ -5865,6 +5866,9 @@ err_init_binder_device_failed:
hlist_del(&device->hlist);
kfree(device);
}
+
+ kfree(device_names);
+
err_alloc_device_names_failed:
debugfs_remove_recursive(binder_debugfs_dir_entry_root);