[PATCH] Fix memory leak in dm_create_persistent() when starting metadata update thread fails.

From: Jesper Juhl
Date: Mon Jul 16 2007 - 15:42:47 EST


If, in dm_create_persistent(), the call to
create_singlethread_workqueue() fails then we'll return without
freeing the memory allocated to 'ps', thus leaking
sizeof(struct pstore) bytes.
This patch fixes the leak.

Signed-off-by: Jesper Juhl <jesper.juhl@xxxxxxxxx
---

diff --git a/drivers/md/dm-exception-store.c b/drivers/md/dm-exception-store.c
index 3d65917..8fe81e1 100644
--- a/drivers/md/dm-exception-store.c
+++ b/drivers/md/dm-exception-store.c
@@ -623,6 +623,7 @@ int dm_create_persistent(struct exception_store *store)

ps->metadata_wq = create_singlethread_workqueue("ksnaphd");
if (!ps->metadata_wq) {
+ kfree(ps);
DMERR("couldn't start header metadata update thread");
return -ENOMEM;
}


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/