mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-06 01:15:20 +02:00
ANDROID: rust_binder: fix leak of name in binderfs
The `rust_binder_new_device` method just makes a copy of the provided c
string, and does not take ownership of it. This means that there's no
reason to kmemdup the string. Also, outside of the error path, the name
is not freed.
Fixes: 0d512d37b0
("ANDROID: rust_binder: add binderfs support to Rust binder")
Change-Id: I4cb63ff0c46d04da7f9debfa9896113779856c02
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
This commit is contained in:
parent
0dcde40390
commit
013c5ddc64
|
@ -139,8 +139,6 @@ static int binderfs_binder_device_create(struct inode *ref_inode,
|
|||
int minor, ret;
|
||||
struct dentry *dentry, *root;
|
||||
rust_binder_device device = NULL;
|
||||
char *name = NULL;
|
||||
size_t name_len;
|
||||
struct inode *inode = NULL;
|
||||
struct super_block *sb = ref_inode->i_sb;
|
||||
struct binderfs_info *info = sb->s_fs_info;
|
||||
|
@ -168,13 +166,8 @@ static int binderfs_binder_device_create(struct inode *ref_inode,
|
|||
|
||||
ret = -ENOMEM;
|
||||
req->name[BINDERFS_MAX_NAME] = '\0'; /* NUL-terminate */
|
||||
name_len = strlen(req->name);
|
||||
/* Make sure to include terminating NUL byte */
|
||||
name = kmemdup(req->name, name_len + 1, GFP_KERNEL);
|
||||
if (!name)
|
||||
goto err;
|
||||
|
||||
device = rust_binder_new_device(name);
|
||||
device = rust_binder_new_device(req->name);
|
||||
if (!device)
|
||||
goto err;
|
||||
|
||||
|
@ -202,7 +195,7 @@ static int binderfs_binder_device_create(struct inode *ref_inode,
|
|||
inode_lock(d_inode(root));
|
||||
|
||||
/* look it up */
|
||||
dentry = lookup_one_len(name, root, name_len);
|
||||
dentry = lookup_one_len(req->name, root, strlen(req->name));
|
||||
if (IS_ERR(dentry)) {
|
||||
inode_unlock(d_inode(root));
|
||||
ret = PTR_ERR(dentry);
|
||||
|
@ -225,7 +218,6 @@ static int binderfs_binder_device_create(struct inode *ref_inode,
|
|||
return 0;
|
||||
|
||||
err:
|
||||
kfree(name);
|
||||
rust_binder_remove_device(device);
|
||||
mutex_lock(&binderfs_minors_mutex);
|
||||
--info->device_count;
|
||||
|
|
Loading…
Reference in New Issue
Block a user