aboutsummaryrefslogtreecommitdiffstats
path: root/com32/elflink/ldlinux/kernel.c
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2012-03-09 12:49:50 +0000
committerMatt Fleming <matt.fleming@intel.com>2012-03-23 16:56:16 +0000
commit9f6b6b08feb709ba8af0571ffec0b008b5d255d9 (patch)
tree2f47327af5381eea7ff46f8c9693c4b74c12bde5 /com32/elflink/ldlinux/kernel.c
parent87320b8de8f331b9c1810e98e24426e70b0ae29f (diff)
downloadsyslinux-9f6b6b08feb709ba8af0571ffec0b008b5d255d9.tar.gz
syslinux-9f6b6b08feb709ba8af0571ffec0b008b5d255d9.tar.xz
syslinux-9f6b6b08feb709ba8af0571ffec0b008b5d255d9.zip
ldlinux: Don't alloc initramfs unless initrd= is specified
It only makes sense to allocate memory for 'initramfs' if an initrd= argument was on the command line, otherwise we're wasting memory. Furthermore needlessly allocating 'initramfs' actually caused old kernels, such as memtest86, to fail to run because of the following check in syslinux_boot_kernel(), if (initramfs && hdr.version < 0x0200) goto bail; /* initrd/initramfs not supported */ Move the allocation after we've checked for and found an initrd= argument. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'com32/elflink/ldlinux/kernel.c')
-rw-r--r--com32/elflink/ldlinux/kernel.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/com32/elflink/ldlinux/kernel.c b/com32/elflink/ldlinux/kernel.c
index ed91b76f..6cda6595 100644
--- a/com32/elflink/ldlinux/kernel.c
+++ b/com32/elflink/ldlinux/kernel.c
@@ -16,7 +16,7 @@ const char *append = NULL;
int new_linux_kernel(char *okernel, char *ocmdline)
{
const char *kernel_name;
- struct initramfs *initramfs;
+ struct initramfs *initramfs = NULL;
char *temp;
void *kernel_data;
size_t kernel_len;
@@ -99,16 +99,16 @@ int new_linux_kernel(char *okernel, char *ocmdline)
if (!opt_quiet)
printf("ok\n");
- /* Initialize the initramfs chain */
- initramfs = initramfs_init();
- if (!initramfs)
- goto bail;
-
/* Find and load initramfs */
temp = strstr(cmdline, "initrd=");
if (temp) {
i = 0;
+ /* Initialize the initramfs chain */
+ initramfs = initramfs_init();
+ if (!initramfs)
+ goto bail;
+
temp += strlen("initrd=");
while (*temp != ' ' && *temp)
initrd_name[i++] = *temp++;