Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1716532 > unrolled thread
| Started by | Christian Brauner <christian.brauner@ubuntu.com> |
|---|---|
| First post | 2017-08-21 16:20 +0200 |
| Last post | 2017-08-21 17:00 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 0/1 v2] binder: free memory on error Christian Brauner <christian.brauner@ubuntu.com> - 2017-08-21 16:20 +0200
[PATCH 1/1 v2] binder: free memory on error Christian Brauner <christian.brauner@ubuntu.com> - 2017-08-21 16:20 +0200
Re: [PATCH 1/1 v2] binder: free memory on error Dan Carpenter <dan.carpenter@oracle.com> - 2017-08-21 17:00 +0200
| From | Christian Brauner <christian.brauner@ubuntu.com> |
|---|---|
| Date | 2017-08-21 16:20 +0200 |
| Subject | [PATCH 0/1 v2] binder: free memory on error |
| Message-ID | <ugVIB-5rU-3@gated-at.bofh.it> |
On binder_init() the devices string is duplicated and smashed into individual device names which are passed along. However, if I'm not mistaken the original duplicated string wasn't freed in case binder_init() failed. Christian Changelog v2 2017-08-21 (Thanks Dan!) - use more descriptive commit message - call kfree(device_names) on correct position Christian Brauner (1): binder: free memory on error drivers/android/binder.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.13.3
[toc] | [next] | [standalone]
| From | Christian Brauner <christian.brauner@ubuntu.com> |
|---|---|
| Date | 2017-08-21 16:20 +0200 |
| Subject | [PATCH 1/1 v2] binder: free memory on error |
| Message-ID | <ugVID-5rU-37@gated-at.bofh.it> |
| In reply to | #1716532 |
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>
---
Changelog v2 2017-08-21:
- use more descriptive commit message
- call kfree(device_names) on correct position
---
drivers/android/binder.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index f7665c31feca..a6ae339223f6 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -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 @@ static int __init binder_init(void)
hlist_del(&device->hlist);
kfree(device);
}
+
+ kfree(device_names);
+
err_alloc_device_names_failed:
debugfs_remove_recursive(binder_debugfs_dir_entry_root);
--
2.13.3
[toc] | [prev] | [next] | [standalone]
| From | Dan Carpenter <dan.carpenter@oracle.com> |
|---|---|
| Date | 2017-08-21 17:00 +0200 |
| Subject | Re: [PATCH 1/1 v2] binder: free memory on error |
| Message-ID | <ugWlj-5F5-7@gated-at.bofh.it> |
| In reply to | #1716544 |
On Mon, Aug 21, 2017 at 04:13:28PM +0200, Christian Brauner wrote: > 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> Looks good. Thanks. regards, dan carpenter
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web