Skip to content

Commit

Permalink
[PATCH] free initrd mem adjustment
Browse files Browse the repository at this point in the history
Besides freeing initrd memory, also clear out the now dangling pointers to
it, to make sure accidental late use attempts can be detected.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Jan Beulich authored and Linus Torvalds committed Sep 13, 2005
1 parent a1a5b3d commit 0f3d2bd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions init/initramfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,14 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only)
extern char __initramfs_start[], __initramfs_end[];
#ifdef CONFIG_BLK_DEV_INITRD
#include <linux/initrd.h>

static void __init free_initrd(void)
{
free_initrd_mem(initrd_start, initrd_end);
initrd_start = 0;
initrd_end = 0;
}

#endif

void __init populate_rootfs(void)
Expand All @@ -484,7 +492,7 @@ void __init populate_rootfs(void)
printk(" it is\n");
unpack_to_rootfs((char *)initrd_start,
initrd_end - initrd_start, 0);
free_initrd_mem(initrd_start, initrd_end);
free_initrd();
return;
}
printk("it isn't (%s); looks like an initrd\n", err);
Expand All @@ -493,7 +501,7 @@ void __init populate_rootfs(void)
sys_write(fd, (char *)initrd_start,
initrd_end - initrd_start);
sys_close(fd);
free_initrd_mem(initrd_start, initrd_end);
free_initrd();
}
}
#endif
Expand Down

0 comments on commit 0f3d2bd

Please sign in to comment.