Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10438471imu; Thu, 6 Dec 2018 00:46:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/X8oGl6ni9HIXWPejtY2q+5AaW11o9Pn1XC7w9PK+nLMMt5jw9XCeixI7Kx5Z1rtxZ8Nbdt X-Received: by 2002:a63:6984:: with SMTP id e126mr23606076pgc.143.1544085967014; Thu, 06 Dec 2018 00:46:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544085966; cv=none; d=google.com; s=arc-20160816; b=Ghr3lIprtOULn7RXfFeGub4+9z2HN7bfrDwqpP2Fu4rlYMBDqcR7CVrjyV7P7cl25W nUFCZ86UmrbfdPI1BXn2B1Ed4MlqfsgXGle6HuhBl33NYHK7eH+soAPIFLoxKwQ3+JVc veZwWl7Gq1DJnMCwRQ44lUxCWdHkKsCAzVACZGZg0gUpo7jDzFFSwXJHU4nUJ4TConWV Ypaggb5jGt+ER2qSmhuyICueRFjvczQKNKeqmKCBTdWfBDrRRCeoWsqRXYh8zZJzmZBt qagrs/q+o+v4+yNH8KpB1UdJ+y4nU6YXSGmZH9QZom9DRVs3SLy+ROCmYSwACmMo08QU UYbQ== 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=KIxrVR0SKEo718qNhtGUg4NzgPpsAs4AE1/4SIGrFXo=; b=qinC5qefpOTdyY5ZMTk25ntIhFmJSF/ECp6PnX4x7IilL0n2aorUwuUb/miNFVGQtn 6m8VE/AJHcNW0+Vk5nvnbqnCTB2lKziu8fv6zA6QEUGdF82p81vGKUqxi5WmM33J05Uf JLaFVH09vmHDxzhnPNKuWqd//lHakaR/j2/zGpTHEAsE67im272X9EXNwVkxNpnHFifg CCA/vXvsgJ2T3Fcd+zSBHqrER8vFyyXQ1ADvz6JNsc5T5GMNH288cxLASCP5EWNhvVwa LJEuLf1dy6uM51VdpTeqFOoffHpW4tgcpC5lp+1mAZbVYrW6aTFHNm06qNsSTrvrmWi/ b7vA== 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 u22si18767963pgh.286.2018.12.06.00.45.51; Thu, 06 Dec 2018 00:46:06 -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 S1728250AbeLFIn6 (ORCPT + 99 others); Thu, 6 Dec 2018 03:43:58 -0500 Received: from mxhk.zte.com.cn ([63.217.80.70]:33260 "EHLO mxhk.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727575AbeLFIn6 (ORCPT ); Thu, 6 Dec 2018 03:43:58 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 9E7647B1CEEFA50B69E0; Thu, 6 Dec 2018 16:43:52 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id wB68hilO035360; Thu, 6 Dec 2018 16:43:44 +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 2018120616441495-15101499 ; Thu, 6 Dec 2018 16:44:14 +0800 From: Wen Yang To: Mark Fasheh , Joel Becker Cc: ocfs2-devel@oss.oracle.com, linux-kernel@vger.kernel.org, zhong.weidong@zte.com.cn, Wen Yang Subject: [PATCH] ocfs2: fix memdup.cocci warnings Date: Thu, 6 Dec 2018 16:43:25 +0800 Message-Id: <20181206084325.20773-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 16:44:15, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-12-06 16:43:32 Content-Transfer-Encoding: quoted-printable X-MAIL: mse01.zte.com.cn wB68hilO035360 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org fs/ocfs2/localalloc.c:1289:14-21: WARNING opportunity for kmemdup fs/ocfs2/localalloc.c:441:14-21: WARNING opportunity for kmemdup Use kmemdup rather than duplicating its implementation Generated by: scripts/coccinelle/api/memdup.cocci Signed-off-by: Wen Yang CC: Mark Fasheh CC: Joel Becker CC: ocfs2-devel@oss.oracle.com CC: linux-kernel@vger.kernel.org --- fs/ocfs2/localalloc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c index 58973e4d2471..3f3047fb934b 100644 --- a/fs/ocfs2/localalloc.c +++ b/fs/ocfs2/localalloc.c @@ -438,12 +438,11 @@ void ocfs2=5Fshutdown=5Flocal=5Falloc(struct ocfs2=5F= super *osb) bh =3D osb->local=5Falloc=5Fbh; alloc =3D (struct ocfs2=5Fdinode *) bh->b=5Fdata; =20 - alloc=5Fcopy =3D kmalloc(bh->b=5Fsize, GFP=5FNOFS); + alloc=5Fcopy =3D kmemdup(alloc, bh->b=5Fsize, GFP=5FNOFS); if (!alloc=5Fcopy) { status =3D -ENOMEM; goto out=5Fcommit; } - memcpy(alloc=5Fcopy, alloc, bh->b=5Fsize); =20 status =3D ocfs2=5Fjournal=5Faccess=5Fdi(handle, INODE=5FCACHE(local=5Fal= loc=5Finode), bh, OCFS2=5FJOURNAL=5FACCESS=5FWRITE); @@ -1286,13 +1285,12 @@ static int ocfs2=5Flocal=5Falloc=5Fslide=5Fwindow(s= truct ocfs2=5Fsuper *osb, * local alloc shutdown won't try to double free main bitmap * bits. Make a copy so the sync function knows which bits to * free. */ - alloc=5Fcopy =3D kmalloc(osb->local=5Falloc=5Fbh->b=5Fsize, GFP=5FNOFS); + alloc=5Fcopy =3D kmemdup(alloc, osb->local=5Falloc=5Fbh->b=5Fsize, GFP=5F= NOFS); if (!alloc=5Fcopy) { status =3D -ENOMEM; mlog=5Ferrno(status); goto bail; } - memcpy(alloc=5Fcopy, alloc, osb->local=5Falloc=5Fbh->b=5Fsize); =20 status =3D ocfs2=5Fjournal=5Faccess=5Fdi(handle, INODE=5FCACHE(local=5Falloc=5Finode), --=20 2.19.1