Skip to contentSkip to conversation

dm crypt: drop device ref in ctr error path

PATCH In review Alasdair G Kergon 1 participant 1 message Oct 12, 2007 Device mapper

lore
Share & tools
lore

Alasdair G Kergon

author maintainer
#0 lore raw

PATCH 3/25 dm crypt: drop device ref in ctr error path

From: Dmitry Monakhov <[email protected]>

Add a missing 'dm_put_device' in an error path in crypt target constructor.

---
 drivers/md/dm-crypt.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletion(-)
drivers/md/dm-crypt.c +3 -1
Index: linux-2.6.23/drivers/md/dm-crypt.c
===================================================================
@@ -882,7 +882,7 @@ static int crypt_ctr(struct dm_target *t
 		cc->iv_mode = kmalloc(strlen(ivmode) + 1, GFP_KERNEL);
 		if (!cc->iv_mode) {
 			ti->error = "Error kmallocing iv_mode string";
-			goto bad5;
+			goto bad_iv_mode;
 		}
 		strcpy(cc->iv_mode, ivmode);
 	} else
@@ -891,6 +891,8 @@ static int crypt_ctr(struct dm_target *t
 	ti->private = cc;
 	return 0;
 
+bad_iv_mode:
+	dm_put_device(ti, cc->dev);
 bad5:
 	bioset_free(cc->bs);
 bad_bs: