From: Rusty Russell <rusty@rustcorp.com.au>
To: weiyj_lk@163.com
Cc: Wei Yongjun <yongjun_wei@trendmicro.com.cn>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH -next] module: use kmemdup rather than duplicating its implementation
Date: Tue, 19 Jul 2016 06:07:05 +0930 [thread overview]
Message-ID: <87h9bmof7y.fsf@rustcorp.com.au> (raw)
In-Reply-To: <1468414187-3070-1-git-send-email-weiyj_lk@163.com>
weiyj_lk@163.com writes:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>
> Use kmemdup rather than duplicating its implementation.
>
> Generated by: scripts/coccinelle/api/memdup.cocci
>
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Hi Wei!
This code has been removed by other changes in modules-next,
so your very nice cleanup is no longer necessary.
Thanks!
Rusty.
> ---
> kernel/module.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/module.c b/kernel/module.c
> index beaebea..04de59f 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -1994,21 +1994,20 @@ 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;
prev parent reply other threads:[~2016-07-18 23:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-13 12:49 [PATCH -next] module: use kmemdup rather than duplicating its implementation weiyj_lk
2016-07-18 20:37 ` Rusty Russell [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h9bmof7y.fsf@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=weiyj_lk@163.com \
--cc=yongjun_wei@trendmicro.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox