diff options
author | zhong jiang <zhongjiang@huawei.com> | 2018-08-01 00:56:17 +0800 |
---|---|---|
committer | Jessica Yu <jeyu@kernel.org> | 2018-08-02 18:03:17 +0200 |
commit | 9be936f4b3a2ec101f54cff9cf1a6abf67263c50 (patch) | |
tree | 3ee7695f2ee3179bd69b52d1d1b9fbba599cfcf3 /kernel/module.c | |
parent | 4d58e7034d1971436d44f203cf69d2feb6b82e5c (diff) | |
download | op-kernel-dev-9be936f4b3a2ec101f54cff9cf1a6abf67263c50.zip op-kernel-dev-9be936f4b3a2ec101f54cff9cf1a6abf67263c50.tar.gz |
kernel/module: Use kmemdup to replace kmalloc+memcpy
we prefer to the kmemdup rather than kmalloc+memcpy. so just
replace them.
Signed-off-by: zhong jiang <zhongjiang@huawei.com>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
Diffstat (limited to 'kernel/module.c')
-rw-r--r-- | kernel/module.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/kernel/module.c b/kernel/module.c index 8a45986..54fbac8 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -2039,21 +2039,19 @@ static int copy_module_elf(struct module *mod, struct load_info *info) /* Elf section header table */ size = sizeof(*info->sechdrs) * info->hdr->e_shnum; - mod->klp_info->sechdrs = kmalloc(size, GFP_KERNEL); + mod->klp_info->sechdrs = kmemdup(info->sechdrs, size, GFP_KERNEL); if (mod->klp_info->sechdrs == NULL) { ret = -ENOMEM; goto free_info; } - memcpy(mod->klp_info->sechdrs, info->sechdrs, size); /* Elf section name string table */ size = info->sechdrs[info->hdr->e_shstrndx].sh_size; - mod->klp_info->secstrings = kmalloc(size, GFP_KERNEL); + mod->klp_info->secstrings = kmemdup(info->secstrings, size, GFP_KERNEL); if (mod->klp_info->secstrings == NULL) { ret = -ENOMEM; goto free_sechdrs; } - memcpy(mod->klp_info->secstrings, info->secstrings, size); /* Elf symbol section index */ symndx = info->index.sym; |