From patchwork Wed Mar 4 20:04:18 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 9918 X-Patchwork-Delegate: agk@redhat.com Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n24K5WAx024783 for ; Wed, 4 Mar 2009 20:05:32 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id 35E538E062A; Wed, 4 Mar 2009 15:05:31 -0500 (EST) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id n24K5UCI006483 for ; Wed, 4 Mar 2009 15:05:30 -0500 Received: from mx1.redhat.com (mx1.redhat.com [172.16.48.31]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n24K5Vhj022456; Wed, 4 Mar 2009 15:05:31 -0500 Received: from smtp1.linux-foundation.org (smtp1.linux-foundation.org [140.211.169.13]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n24K5Erp004910; Wed, 4 Mar 2009 15:05:14 -0500 Received: from imap1.linux-foundation.org (imap1.linux-foundation.org [140.211.169.55]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id n24K4JiT011620 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 4 Mar 2009 12:04:20 -0800 Received: from localhost.localdomain (localhost [127.0.0.1]) by imap1.linux-foundation.org (8.13.5.20060308/8.13.5/Debian-3ubuntu1.1) with ESMTP id n24K4JuE029084; Wed, 4 Mar 2009 12:04:19 -0800 Message-Id: <200903042004.n24K4JuE029084@imap1.linux-foundation.org> To: agk@redhat.com From: akpm@linux-foundation.org Date: Wed, 04 Mar 2009 12:04:18 -0800 X-Spam-Status: No, hits=-3.453 required=5 tests=AWL, BAYES_00, OSDL_HEADER_SUBJECT_BRACKETED X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-Scanned-By: MIMEDefang 2.63 on 172.16.48.31 X-Scanned-By: MIMEDefang 2.63 on 140.211.169.13 X-RedHat-Spam-Score: -1.81 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, penberg@cs.helsinki.fi, akpm@linux-foundation.org, hannes@cmpxchg.org Subject: [dm-devel] [patch 1/1] md: use kzfree() X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com From: Johannes Weiner Use kzfree() instead of memset() + kfree(). Signed-off-by: Johannes Weiner Reviewed-by: Pekka Enberg Cc: Alasdair Kergon Signed-off-by: Andrew Morton --- drivers/md/dm-crypt.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff -puN drivers/md/dm-crypt.c~md-use-kzfree drivers/md/dm-crypt.c --- a/drivers/md/dm-crypt.c~md-use-kzfree +++ a/drivers/md/dm-crypt.c @@ -1137,8 +1137,7 @@ bad_ivmode: crypto_free_ablkcipher(tfm); bad_cipher: /* Must zero key material before freeing */ - memset(cc, 0, sizeof(*cc) + cc->key_size * sizeof(u8)); - kfree(cc); + kzfree(cc); return -EINVAL; } @@ -1164,8 +1163,7 @@ static void crypt_dtr(struct dm_target * dm_put_device(ti, cc->dev); /* Must zero key material before freeing */ - memset(cc, 0, sizeof(*cc) + cc->key_size * sizeof(u8)); - kfree(cc); + kzfree(cc); } static int crypt_map(struct dm_target *ti, struct bio *bio,