Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754422Ab3C0X3x (ORCPT ); Wed, 27 Mar 2013 19:29:53 -0400 Received: from mail-da0-f49.google.com ([209.85.210.49]:55723 "EHLO mail-da0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753585Ab3C0X3w (ORCPT ); Wed, 27 Mar 2013 19:29:52 -0400 MIME-Version: 1.0 In-Reply-To: <1364414011-3144-1-git-send-email-gheorghiuandru@gmail.com> References: <1364414011-3144-1-git-send-email-gheorghiuandru@gmail.com> Date: Thu, 28 Mar 2013 08:24:13 +0900 Message-ID: Subject: Re: [PATCH] fs: f2fs: Use kmemdup From: Namjae Jeon To: Alexandru Gheorghiu Cc: Jaegeuk Kim , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2773 Lines: 71 2013/3/28, Alexandru Gheorghiu : > Used kmemdup instead of kzalloc followed by memcpy. > Patch found using coccinelle. > > Signed-off-by: Alexandru Gheorghiu > --- > fs/f2fs/segment.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index 777f17e..1758149 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -1403,10 +1403,9 @@ static int build_sit_info(struct f2fs_sb_info *sbi) > bitmap_size = __bitmap_size(sbi, SIT_BITMAP); > src_bitmap = __bitmap_ptr(sbi, SIT_BITMAP); > > - dst_bitmap = kzalloc(bitmap_size, GFP_KERNEL); > + dst_bitmap = kmemdup(src_bitmap, bitmap_size, GFP_KERNEL); > if (!dst_bitmap) > return -ENOMEM; > - memcpy(dst_bitmap, src_bitmap, bitmap_size); > > /* init SIT information */ > sit_i->s_ops = &default_salloc_ops; > -- > 1.7.9.5 Hi Alexandru. There is another point to change kmemdup. ------------------------------------------------------------------------------------------------------ - nm_i->bitmap_size = __bitmap_size(sbi, NAT_BITMAP); - nm_i->init_scan_nid = le32_to_cpu(sbi->ckpt->next_free_nid); - nm_i->next_scan_nid = le32_to_cpu(sbi->ckpt->next_free_nid); + nm_i->init_scan_nid = le32_to_cpu(sbi->ckpt->next_free_nid); + nm_i->next_scan_nid = le32_to_cpu(sbi->ckpt->next_free_nid); + nm_i->bitmap_size = __bitmap_size(sbi, NAT_BITMAP); + version_bitmap = __bitmap_ptr(sbi, NAT_BITMAP); + if (!version_bitmap) + return -EFAULT; - nm_i->nat_bitmap = kzalloc(nm_i->bitmap_size, GFP_KERNEL); - if (!nm_i->nat_bitmap) - return -ENOMEM; - version_bitmap = __bitmap_ptr(sbi, NAT_BITMAP); - if (!version_bitmap) - return -EFAULT; + nm_i->nat_bitmap = kmemdup(version_bitmap, nm_i->bitmap_size, GFP_KERNEL); + if (!nm_i->nat_bitmap) + return -ENOMEM; - /* copy version bitmap */ - memcpy(nm_i->nat_bitmap, version_bitmap, nm_i->bitmap_size); ----------------------------------------------------------------------------------------------------- If you agree, Could you send the patch include the above one again ? Thanks. > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/