From: Stefan Rompf <[email-masked]>

Zap the memory before freeing it so we don't leave crypto information
around in memory.

Signed-off-by: Stefan Rompf <[email-masked]>
Acked-by: Clemens Fruhwirth <[email-masked]>
Acked-by: Alasdair G Kergon <[email-masked]>
Signed-off-by: Andrew Morton <[email-masked]>

[Included in -mm]

Index: current-quilt-publish/drivers/md/dm-crypt.c
===================================================================
--- current-quilt-publish.orig/drivers/md/dm-crypt.c	2005-10-28 01:02:08.000000000 +0100
+++ current-quilt-publish/drivers/md/dm-crypt.c	2006-01-05 13:57:40.000000000 +0000
@@ -694,6 +694,8 @@ bad3:
 bad2:
 	crypto_free_tfm(tfm);
 bad1:
+	/* Must zero key material before freeing */
+	memset(cc, 0, sizeof(*cc) + cc->key_size * sizeof(u8));
 	kfree(cc);
 	return -EINVAL;
 }
@@ -710,6 +712,9 @@ static void crypt_dtr(struct dm_target *
 		cc->iv_gen_ops->dtr(cc);
 	crypto_free_tfm(cc->tfm);
 	dm_put_device(ti, cc->dev);
+
+	/* Must zero key material before freeing */
+	memset(cc, 0, sizeof(*cc) + cc->key_size * sizeof(u8));
 	kfree(cc);
 }