Re: [pm] fix oops after saving image

From: Patrick Mochel
Date: Fri Oct 03 2003 - 16:31:06 EST



> I do not want to waste 4K, does this look better?
> Pavel
>
> --- tmp/linux/kernel/power/swsusp.c 2003-10-02 22:29:06.000000000 +0200
> +++ linux/kernel/power/swsusp.c 2003-10-02 22:27:07.000000000 +0200
> @@ -283,6 +283,9 @@
> unsigned long address;
> struct page *page;
>
> + if (!buffer)
> + return -ENOMEM;
> +
> printk( "Writing data to swap (%d pages): ", nr_copy_pages );
> for (i=0; i<nr_copy_pages; i++) {
> if (!(i%100))

Argh! This bit was in the previous patch I applied. Please get it
straight, or just keep adding to one patch and resending it (with an
itemized list of changes).

> @@ -345,7 +348,7 @@
> printk( "|\n" );
>
> MDELAY(1000);
> - free_page((unsigned long) buffer);
> + /* No need to free anything, system is going down, anyway. */
> return 0;
> }

It's technically still incorrect, since you'd still be leaking memory if
suspend failed. And, the comment is still in an unfortunate place.
Something like this, before the function helps to provide understanding of
the entire operation:


/**
* write_suspend_image - Write entire image to disk.
*
* ...
*
* Note: The buffer we allocate to use to write the suspend header is
* not freed because it otherwise causes a random Oops that I can't
* find. This is a band-aid that probably only masks the problem, and
* technically bad, since it means we leak memory unconditionally if
* suspend fails.
*/

static int write_suspend_image(void)
...



Pat

-
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/