[Lguest] [PATCH 2.6.28] lguest: LCA09 lguest tutorial - fix memory leak in close()

Mark Wallis lguest at markwallis.id.au
Thu Jan 22 14:23:14 EST 2009


(sorry if this is received twice)

 From Rusty's tutorial, fix the memory leak in close() by using kfree instead of just zeroing the memory.

Signed-off-by: Mark Wallis <lguest at markwallis.id.au>

--- drivers/lguest/lguest_user.c.orig	2009-01-22 10:20:33.000000000 +1100
+++ drivers/lguest/lguest_user.c	2009-01-22 10:55:57.000000000 +1100
@@ -310,9 +310,8 @@
  	 * kmalloc()ed string, either of which is ok to hand to kfree(). */
  	if (!IS_ERR(lg->dead))
  		kfree(lg->dead);
-	/* We clear the entire structure, which also marks it as free for the
-	 * next user. */
-	memset(lg, 0, sizeof(*lg));
+	/* Free the memory allocated to the lguest_struct */
+	kfree(lg);
  	/* Release lock and exit. */
  	mutex_unlock(&lguest_lock);





More information about the Lguest mailing list