Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10451891imu; Thu, 6 Dec 2018 01:04:29 -0800 (PST) X-Google-Smtp-Source: AFSGD/UJ6vH5wUo8zGA7hPPvx91VUg4RE47XGUeAvCXI88IdZ81x+DQZcC3/6KjyNZgjuzmz/NvE X-Received: by 2002:a62:2c81:: with SMTP id s123mr27345122pfs.174.1544087069815; Thu, 06 Dec 2018 01:04:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544087069; cv=none; d=google.com; s=arc-20160816; b=KNqzieUtObI/qE0PbiAUCsn4PSg4l+3UvpCZcz7OYUDevdU1GnCQRjRKgFhqRny8nP 7CccU6sRrGkmCCGNXWhAsNWRYIxMU+fZFjgadk6QnhJtFPNmBcsH4SoZEgggnjkLpmPd Q+8d0sb24gkJ1ncEKKi6/o72BUBD0IKua6uYms85sq/MbeW8SElbh//vc1mlAxjPXDG6 67C/i/EA+JzIkPRJAxeBL5JfjewNXGKJi8Jt7V3RjmBHgvUCxxSVEVNHJnYeNASKrkgD rHkAP/Qg65lNrLpXDn5dgVaL2iwGv9U1kWrPoAvLzaR898nfurO/jt0vN1NRK2Skedmc vJAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=3ZS+m+eZ/iUghuZ3nyvbi22bdsi/WhGNwe+EvbRs5tg=; b=j24hVRTP/XGBHKs2h/e5IsMN2i0Fzlxy9R6ipLuvHJMAlpu+9DwXr2AdrqEV9agl1o cxNsUQaRm+uoeyjaAJwPQx2rdfyWD6jFtbUmk6QM9wevHMwO0tLslXmOzD4ellcXJDbB fLOyfBQeGYiYxUgwYJQToUiAEhdiqVR2RYny9nr50Tjsp4ZTLs/haFNB8iZ4nSYCXbiI hz2TswzMUyPhod6tOgRflThtkRLmU4ZdEM1Xjtt4YS0rzbPrTBxx0S0uHp5AniBMzdLT LAVRi2Tcx9P9N8Mzttt6gW8IYRuownIdFyZx8PMsbTgWslkdEiU0INEZzq2I8cZ04TsW 0Iyg== 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 v8si21669068plp.215.2018.12.06.01.04.13; Thu, 06 Dec 2018 01:04:29 -0800 (PST) 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 S1729267AbeLFJCa (ORCPT + 99 others); Thu, 6 Dec 2018 04:02:30 -0500 Received: from mxhk.zte.com.cn ([63.217.80.70]:65318 "EHLO mxhk.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727832AbeLFJC3 (ORCPT ); Thu, 6 Dec 2018 04:02:29 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 7598CD9DC242AC97C52A; Thu, 6 Dec 2018 17:02:27 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id wB692Hxv071226; Thu, 6 Dec 2018 17:02:17 +0800 (GMT-8) (envelope-from wen.yang99@zte.com.cn) Received: from LIN-A6CB96A0603.zte.intra ([10.90.106.118]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2018120617024798-15105640 ; Thu, 6 Dec 2018 17:02:47 +0800 From: Wen Yang To: Bob Copeland Cc: linux-karma-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, zhong.weidong@zte.com.cn, Wen Yang Subject: [PATCH] omfs: Use kmemdup instead of duplicating its function Date: Thu, 6 Dec 2018 17:02:10 +0800 Message-Id: <20181206090210.39624-1-wen.yang99@zte.com.cn> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2018-12-06 17:02:48, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-12-06 17:02:06 Content-Transfer-Encoding: quoted-printable X-MAIL: mse01.zte.com.cn wB692Hxv071226 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kmemdup has implemented the function that kmalloc() + memcpy(). We prefer to kmemdup rather than code opened implementation. This issue was detected with the help of coccinelle. Signed-off-by: Wen Yang CC: Bob Copeland CC: linux-karma-devel@lists.sourceforge.net CC: linux-kernel@vger.kernel.org --- 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 e5258fefcd2b..195c6baa3c8e 100644 --- a/fs/omfs/inode.c +++ b/fs/omfs/inode.c @@ -363,12 +363,11 @@ static int omfs=5Fget=5Fimap(struct super=5Fblock *sb) bh =3D sb=5Fbread(sb, block++); if (!bh) goto nomem=5Ffree; - *ptr =3D kmalloc(sb->s=5Fblocksize, GFP=5FKERNEL); + *ptr =3D kmemdup(bh->b=5Fdata, sb->s=5Fblocksize, GFP=5FKERNEL); if (!*ptr) { brelse(bh); goto nomem=5Ffree; } - memcpy(*ptr, bh->b=5Fdata, sb->s=5Fblocksize); if (count < sb->s=5Fblocksize) memset((void *)*ptr + count, 0xff, sb->s=5Fblocksize - count); --=20 2.19.1