From patchwork Sat Mar 9 11:49:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Gheorghiu X-Patchwork-Id: 2836833 Return-Path: X-Original-To: patchwork-ocfs2-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D189B9F9C8 for ; Thu, 1 Aug 2013 07:28:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C2E112026C for ; Thu, 1 Aug 2013 07:28:15 +0000 (UTC) Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 67FF120263 for ; Thu, 1 Aug 2013 07:28:14 +0000 (UTC) Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r717S1KI001653 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 1 Aug 2013 07:28:02 GMT Received: from oss.oracle.com (oss-external.oracle.com [137.254.96.51]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r717RxT0003623 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 1 Aug 2013 07:27:59 GMT Received: from localhost ([127.0.0.1] helo=oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1V4nIl-0005c6-Ji; Thu, 01 Aug 2013 00:27:59 -0700 Received: from ucsinet22.oracle.com ([156.151.31.94]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1UEp4X-0002A6-8f for ocfs2-devel@oss.oracle.com; Sun, 10 Mar 2013 15:50:29 -0700 Received: from aserp1030.oracle.com (aserp1030.oracle.com [141.146.126.68]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r2AMoSV0020643 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 10 Mar 2013 22:50:28 GMT Received: from mail-ee0-f48.google.com (mail-ee0-f48.google.com [74.125.83.48]) by aserp1030.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r2AMoQYq021407 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Sun, 10 Mar 2013 22:50:27 GMT Received: by mail-ee0-f48.google.com with SMTP id t10so1853069eei.7 for ; Sun, 10 Mar 2013 15:50:26 -0700 (PDT) X-Received: by 10.14.111.72 with SMTP id v48mr30163775eeg.11.1362955826002; Sun, 10 Mar 2013 15:50:26 -0700 (PDT) Received: from localhost.localdomain ([109.100.227.88]) by mx.google.com with ESMTPS id q5sm20288293eeo.17.2013.03.10.15.50.24 (version=TLSv1 cipher=DES-CBC3-SHA bits=168/168); Sun, 10 Mar 2013 15:50:25 -0700 (PDT) From: Alexandru Gheorghiu To: Mark Fasheh Date: Sat, 9 Mar 2013 13:49:37 +0200 Message-Id: <1362829777-6924-1-git-send-email-gheorghiuandru@gmail.com> X-Mailer: git-send-email 1.7.9.5 X-Flow-Control-Info: class=Pass-to-MM reputation=ipRiskAll ip=74.125.83.48 ct-class=R6 ct-vol1=0 ct-vol2=0 ct-vol3=0 ct-risk=68 ct-spam1=0 ct-spam2=0 ct-bulk=0 rcpts=1 size=1538 X-Sendmail-CM-Score: 0.00% X-Sendmail-CM-Analysis: v=2.0 cv=GtZrCzJC c=1 sm=1 a=W7/4XBAGIWDAbiWrFR2fAA==:17 a=kzZTw6gPw54A:10 a=nDghuxUhq_wA:10 a=pGLkceISAAAA:8 a=coh-tORve5wA:10 a=kJsym2xKAo_zsH1VssIA:9 a=MSl-tDqOz04A:10 a=Q0qV3C1VKd6AZD6JZY9OBg==:117 X-Sendmail-CT-Classification: not spam X-Sendmail-CT-RefID: str=0001.0A090207.513D0E34.000B, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-Mailman-Approved-At: Thu, 01 Aug 2013 00:27:57 -0700 Cc: Alexandru Gheorghiu , ocfs2-devel@oss.oracle.com, linux-kernel@vger.kernel.org Subject: [Ocfs2-devel] [PATCH] fs: fs2fs: Replaced calls to kmalloc and memcpy with kmemdup X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Source-IP: acsinet22.oracle.com [141.146.126.238] X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, DATE_IN_PAST_24_48, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Replaced calls to kmalloc followd by memcpy with a single call to kmemdup. This patch was found using coccicheck. Signed-off-by: Alexandru Gheorghiu --- 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 aebeacd..839183f 100644 --- a/fs/ocfs2/localalloc.c +++ b/fs/ocfs2/localalloc.c @@ -434,12 +434,11 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) bh = osb->local_alloc_bh; alloc = (struct ocfs2_dinode *) bh->b_data; - alloc_copy = kmalloc(bh->b_size, GFP_NOFS); + alloc_copy = kmemdup(alloc, bh->b_size, GFP_NOFS); if (!alloc_copy) { status = -ENOMEM; goto out_commit; } - memcpy(alloc_copy, alloc, bh->b_size); status = ocfs2_journal_access_di(handle, INODE_CACHE(local_alloc_inode), bh, OCFS2_JOURNAL_ACCESS_WRITE); @@ -1244,13 +1243,12 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *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_copy = kmalloc(osb->local_alloc_bh->b_size, GFP_NOFS); + alloc_copy = kmemdup(alloc, osb->local_alloc_bh->b_size, GFP_NOFS); if (!alloc_copy) { status = -ENOMEM; mlog_errno(status); goto bail; } - memcpy(alloc_copy, alloc, osb->local_alloc_bh->b_size); status = ocfs2_journal_access_di(handle, INODE_CACHE(local_alloc_inode),