]> git.hungrycats.org Git - linux/commitdiff
binder: free memory on error
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 21 Aug 2017 14:13:28 +0000 (16:13 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 9 Sep 2017 15:39:30 +0000 (17:39 +0200)
commit 22eb9476b5d80a393ac0ba235c42bccc90b82c76 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/android/binder.c

index 831cdd7d197dbed87d8a55c530af8df50da15419..3db96b79d122f9045b7fb0531dbf5e57570412d1 100644 (file)
@@ -4215,7 +4215,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;
 
@@ -4263,7 +4263,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;
@@ -4277,6 +4278,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);