Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751622AbbHGIIw (ORCPT ); Fri, 7 Aug 2015 04:08:52 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:21625 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422656AbbHGIAo (ORCPT ); Fri, 7 Aug 2015 04:00:44 -0400 X-AuditID: cbfec7f5-f794b6d000001495-26-55c465ab6be3 From: Andrzej Hajda To: Anton Altaparmakov Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Marek Szyprowski , linux-kernel@vger.kernel.org, linux-ntfs-dev@lists.sourceforge.net Subject: [PATCH 22/31] fs/ntfs: use kmemdup rather than duplicating its implementation Date: Fri, 07 Aug 2015 09:59:28 +0200 Message-id: <1438934377-4922-23-git-send-email-a.hajda@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1438934377-4922-1-git-send-email-a.hajda@samsung.com> References: <1438934377-4922-1-git-send-email-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupiluLIzCtJLcpLzFFi42I5/e/4Fd3VqUdCDTbP17S4te4cq8XOTVtY LTbOWM9qcXnXHDaL9o45jBZrj9xld2Dz2L3gM5NH35ZVjB4rVr5n8vi8SS6AJYrLJiU1J7Ms tUjfLoErY/L136wF/ZwVV6ZeZ2xgPMLexcjJISFgIvH5xixmCFtM4sK99WxdjFwcQgJLGSXu rdnPDOE0MUm0PdvPAlLFJqAp8XfzTaAqDg4RIHvVrxqQGmaBK4wSc3Y3gk0SFoiQuLL0I5jN IqAqcbHjBVgvr4CzxPu116A2y0mcPDaZFcTmBIqv7J4JZgsJOEm86bvAPIGRdwEjwypG0dTS 5ILipPRcI73ixNzi0rx0veT83E2MkBD6uoNx6TGrQ4wCHIxKPLwJ/w6HCrEmlhVX5h5ilOBg VhLhfagPFOJNSaysSi3Kjy8qzUktPsQozcGiJM47c9f7ECGB9MSS1OzU1ILUIpgsEwenVAMj 16TVDQtkjx/eN4OhKNC1JFllz8tFv+SnLueatHBzuUjRFOUkA74Lt/rW950WLI1Mj3W/dc/+ rPskw+vn+9Urtc2WcTUYrXxq4ldpOjc7RGap/MI1L7orDkTfftxpxR/pbcPetSnR/exlnwsu jD07C8XKI1UTWhauE6gyXrWJb5F8XNwPp19KLMUZiYZazEXFiQDLMF8VHQIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1377 Lines: 40 The patch was generated using fixed coccinelle semantic patch scripts/coccinelle/api/memdup.cocci [1]. [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320 Signed-off-by: Andrzej Hajda --- fs/ntfs/dir.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c index 9e38daf..2b7fef0 100644 --- a/fs/ntfs/dir.c +++ b/fs/ntfs/dir.c @@ -1172,14 +1172,13 @@ static int ntfs_readdir(struct file *file, struct dir_context *actor) * map the mft record without deadlocking. */ rc = le32_to_cpu(ctx->attr->data.resident.value_length); - ir = kmalloc(rc, GFP_NOFS); + /* Copy the index root value (it has been verified in read_inode). */ + ir = kmemdup((u8 *)ctx->attr + le16_to_cpu(ctx->attr->data.resident.value_offset), + rc, GFP_NOFS); if (unlikely(!ir)) { err = -ENOMEM; goto err_out; } - /* Copy the index root value (it has been verified in read_inode). */ - memcpy(ir, (u8*)ctx->attr + - le16_to_cpu(ctx->attr->data.resident.value_offset), rc); ntfs_attr_put_search_ctx(ctx); unmap_mft_record(ndir); ctx = NULL; -- 1.9.1 -- 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/