Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1561916ybe; Mon, 2 Sep 2019 23:44:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxr+xlaWDPtnol1F5/hiRPqPRVn52hO9+QWXUsGUHKqYljLMAl2t563po4Qx2q/jNRLIo7i X-Received: by 2002:a65:6216:: with SMTP id d22mr26709711pgv.404.1567493041174; Mon, 02 Sep 2019 23:44:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567493041; cv=none; d=google.com; s=arc-20160816; b=PxInDzY9RYImnrZzpahKODmK0tohFM69Lruewvl7Ltx53UXNAJjzL/tjzZeO661xSn UlIKtXHhhAQ1LosklbyT1USXgrPwUbi9c1Cj8gAgUvpkG7qGkWZAStYjKlGj666cTTuf 06yXv9ycmO6uOwDct2/bPmUwD6CGRZM3GwHHB8Z9gFolV3D58wHqL93W7Qtcy4LeOMUw +Xfow1T8wJq23El6ZXDIHXAjOc/JkfvxeUp+guo4lZ43+zM5700DZxbYKCrJBG4+fbrX Lg1wm0zOAyigAAdlFaxxhziYfym/KwoHHIvG3tKmuBJeSkuzFPTzp4lstWmeHqWTNffW YtWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=oxRUDeJjv9GlaAYdG9qJzPtHj0VmFWz07Q4U6TozJ9E=; b=pSvGVQppKSVnbL64CY4X6TxI8vUi+jvEzFwhF4Pc2LmZsqKI/bAkp2kvx1dxSWzxGe 3xdan1KINrsm+HR4xQHNNaCAJmt1vK7R90EOCHrGQxouqw9NVXi+e6CSB6BlG1mFGOzl FDAnumf0a8fx9xQonHm26H3+Y8PZMnbEgbPO3F9myRFX2fiy1/9oGbF/WrVqyFy2RD13 RzfihsNb2YOYR3uQaHsbz0rBUE+Hw2zXH1TA3Ans0KlcyGStnBr0j5ftJuinyCLNfasC kxi6tl3TZb1JYtzTq62DNFOCYwUDJxPjTf4IH193tCx3ZtXLczyZvtW88PSy/df2lIAV i8cg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a14si13909748pjs.69.2019.09.02.23.43.45; Mon, 02 Sep 2019 23:44:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726910AbfICGmr (ORCPT + 99 others); Tue, 3 Sep 2019 02:42:47 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:34000 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725919AbfICGmq (ORCPT ); Tue, 3 Sep 2019 02:42:46 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id CFC12872195C1A84D3AA; Tue, 3 Sep 2019 14:42:44 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.439.0; Tue, 3 Sep 2019 14:42:39 +0800 From: zhong jiang To: CC: , , Subject: [PATCH] fs: omfs: Use kmemdup rather than duplicating its implementation in omfs_get_imap Date: Tue, 3 Sep 2019 14:39:44 +0800 Message-ID: <1567492784-19304-1-git-send-email-zhongjiang@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kmemdup contains the kmalloc + memcpy. hence it is better to use kmemdup directly. Just replace it. Signed-off-by: zhong jiang --- fs/omfs/inode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c index b76ec6b..8867cef 100644 --- a/fs/omfs/inode.c +++ b/fs/omfs/inode.c @@ -363,12 +363,11 @@ static int omfs_get_imap(struct super_block *sb) bh = sb_bread(sb, block++); if (!bh) goto nomem_free; - *ptr = kmalloc(sb->s_blocksize, GFP_KERNEL); + *ptr = kmemdup(bh->b_data, sb->s_blocksize, GFP_KERNEL); if (!*ptr) { brelse(bh); goto nomem_free; } - memcpy(*ptr, bh->b_data, sb->s_blocksize); if (count < sb->s_blocksize) memset((void *)*ptr + count, 0xff, sb->s_blocksize - count); -- 1.7.12.4