[PATCH] swsusp: prevent possible memory leak
authorRafael J. Wysocki <rjw@sisk.pl>
Wed, 28 Sep 2005 04:45:32 +0000 (21:45 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Wed, 28 Sep 2005 14:46:40 +0000 (07:46 -0700)
Prevent swsusp from leaking some memory in case of an error in
read_pagedir().  It also prevents the BUG_ON() from triggering if there's
an error while reading swap.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
kernel/power/swsusp.c

index 8aef1b49150fe7fad4d8fe496ab74ccedde7be53..0dfb2494890794161c4645ba657d546870a7661b 100644 (file)
@@ -1437,9 +1437,9 @@ static int read_pagedir(struct pbe *pblist)
        }
 
        if (error)
-               free_page((unsigned long)pblist);
-
-       BUG_ON(i != swsusp_info.pagedir_pages);
+               free_pagedir(pblist);
+       else
+               BUG_ON(i != swsusp_info.pagedir_pages);
 
        return error;
 }