From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752266AbcGRXqr (ORCPT ); Mon, 18 Jul 2016 19:46:47 -0400 Received: from ozlabs.org ([103.22.144.67]:56199 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751799AbcGRXqq (ORCPT ); Mon, 18 Jul 2016 19:46:46 -0400 From: Rusty Russell To: weiyj_lk@163.com Cc: Wei Yongjun , linux-kernel@vger.kernel.org Subject: Re: [PATCH -next] module: use kmemdup rather than duplicating its implementation In-Reply-To: <1468414187-3070-1-git-send-email-weiyj_lk@163.com> References: <1468414187-3070-1-git-send-email-weiyj_lk@163.com> User-Agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-pc-linux-gnu) Date: Tue, 19 Jul 2016 06:07:05 +0930 Message-ID: <87h9bmof7y.fsf@rustcorp.com.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org weiyj_lk@163.com writes: > From: Wei Yongjun > > Use kmemdup rather than duplicating its implementation. > > Generated by: scripts/coccinelle/api/memdup.cocci > > Signed-off-by: Wei Yongjun 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;