Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

lguest: Fix a memory leak with the lg object during launcher close

Fix a memory leak identified by Rusty Russell during LCA09 by
kfree'ing the lg object instead of just clearing it when the
launcher closes.

Signed-off-by: Mark Wallis <mwallis@serialmonkey.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

authored by

Mark Wallis and committed by
Rusty Russell
05dfdbbd b44d49ab

+2 -3
+2 -3
drivers/lguest/lguest_user.c
··· 307 307 * kmalloc()ed string, either of which is ok to hand to kfree(). */ 308 308 if (!IS_ERR(lg->dead)) 309 309 kfree(lg->dead); 310 - /* We clear the entire structure, which also marks it as free for the 311 - * next user. */ 312 - memset(lg, 0, sizeof(*lg)); 310 + /* Free the memory allocated to the lguest_struct */ 311 + kfree(lg); 313 312 /* Release lock and exit. */ 314 313 mutex_unlock(&lguest_lock); 315 314