]> git.ozlabs.org Git - yaboot.git/commitdiff
Pretend to allocate/deallocate memory correctly
authorEthan Benson <erbenson@alaska.net>
Fri, 29 Jul 2005 04:29:18 +0000 (04:29 +0000)
committerEthan Benson <erbenson@alaska.net>
Fri, 29 Jul 2005 04:29:18 +0000 (04:29 +0000)
* Pretend like we actually manage memory properly by calling free() on
  things which were malloc()'ed or strdup()'ed.
  (Patch from Dustin Kirkland).
git-archimport-id: erbenson@alaska.net--public/yaboot--devel--1.3--patch-84

0arch-timestamps0
ChangeLog
second/file.c
second/partition.c
second/yaboot.c

index 0a2f69e066a46f743992d6ed5c29351d4d4ecbd5..84bd38c7ddf3299afed0560f6866294c493ef179 100644 (file)
@@ -1,7 +1,7 @@
-./0arch-timestamps0    1120448537      1120953071
+./0arch-timestamps0    1120953079      1122611350
 ./BUGS 1109049412      1000991730
 ./COPYING      1109049412      1000991730
 ./BUGS 1109049412      1000991730
 ./COPYING      1109049412      1000991730
-./ChangeLog    1120952850      1120953067
+./ChangeLog    1122611216      1122611345
 ./Config       1109049412      1002101497
 ./INSTALL      1109049412      1000991730
 ./Makefile     1109049412      1089576723
 ./Config       1109049412      1002101497
 ./INSTALL      1109049412      1000991730
 ./Makefile     1109049412      1089576723
 ./doc/examples/simpleboot.chrp 1109049412      1068017750
 ./doc/examples/yaboot.conf.multi-boot  1109049412      1006348765
 ./doc/examples/yaboot.conf.rs6000      1109049412      1006348765
 ./doc/examples/simpleboot.chrp 1109049412      1068017750
 ./doc/examples/yaboot.conf.multi-boot  1109049412      1006348765
 ./doc/examples/yaboot.conf.rs6000      1109049412      1006348765
-./doc/examples 1120953070      1068017750
+./doc/examples 1122611349      1068017750
 ./doc/yaboot-howto.de.sgml     1109049413      1096186109
 ./doc/yaboot-howto.sgml        1109049413      1096186082
 ./doc/yaboot-howto.de.sgml     1109049413      1096186109
 ./doc/yaboot-howto.sgml        1109049413      1096186082
-./doc  1120953070      1096186109
+./doc  1122611349      1096186109
 ./etc/yaboot.conf      1109049413      1006348765
 ./etc/yaboot.conf      1109049413      1006348765
-./etc  1120953070      1007269243
+./etc  1122611349      1007269243
 ./first/ofboot 1118285749      1065311880
 ./first/ofboot 1118285749      1065311880
-./first        1120953070      1071492158
+./first        1122611349      1071492158
 ./include/asm/elf.h    1109049413      1000991730
 ./include/asm/ppc_asm.tmpl     1109049413      1000991730
 ./include/asm/processor.h      1109049413      1000991730
 ./include/asm/elf.h    1109049413      1000991730
 ./include/asm/ppc_asm.tmpl     1109049413      1000991730
 ./include/asm/processor.h      1109049413      1000991730
-./include/asm  1120953071      1007269243
+./include/asm  1122611349      1007269243
 ./include/bootinfo.h   1109049413      1007200690
 ./include/byteorder.h  1109049413      1000991730
 ./include/cfg.h        1109049413      1007200690
 ./include/bootinfo.h   1109049413      1007200690
 ./include/byteorder.h  1109049413      1000991730
 ./include/cfg.h        1109049413      1007200690
 ./include/debug.h      1109049413      1007200690
 ./include/errors.h     1109049413      1007200690
 ./include/et/com_err.h 1109049413      1000991731
 ./include/debug.h      1109049413      1007200690
 ./include/errors.h     1109049413      1007200690
 ./include/et/com_err.h 1109049413      1000991731
-./include/et   1120953071      1007269243
+./include/et   1122611349      1007269243
 ./include/ext2fs/bitops.h      1109049413      1003927524
 ./include/ext2fs/ext2_err.h    1109049413      1003927524
 ./include/ext2fs/ext2_io.h     1109049413      1003927524
 ./include/ext2fs/ext2fs.h      1109049413      1003927524
 ./include/ext2fs/bitops.h      1109049413      1003927524
 ./include/ext2fs/ext2_err.h    1109049413      1003927524
 ./include/ext2fs/ext2_io.h     1109049413      1003927524
 ./include/ext2fs/ext2fs.h      1109049413      1003927524
-./include/ext2fs       1120953071      1007269243
+./include/ext2fs       1122611350      1007269243
 ./include/file.h       1109049413      1007200690
 ./include/fs.h 1109049413      1007200690
 ./include/linux/elf.h  1109049413      1000991731
 ./include/file.h       1109049413      1007200690
 ./include/fs.h 1109049413      1007200690
 ./include/linux/elf.h  1109049413      1000991731
 ./include/linux/iso_fs.h       1109049413      1000991731
 ./include/linux/stat.h 1109049413      1000991731
 ./include/linux/types.h        1109049413      1000991731
 ./include/linux/iso_fs.h       1109049413      1000991731
 ./include/linux/stat.h 1109049413      1000991731
 ./include/linux/types.h        1109049413      1000991731
-./include/linux        1120953071      1007269243
+./include/linux        1122611350      1007269243
 ./include/mac-part.h   1109049413      1007200690
 ./include/md5.h        1109049413      1000991730
 ./include/prom.h       1109049413      1007200690
 ./include/reiserfs/reiserfs.h  1109049413      1025684115
 ./include/mac-part.h   1109049413      1007200690
 ./include/md5.h        1109049413      1000991730
 ./include/prom.h       1109049413      1007200690
 ./include/reiserfs/reiserfs.h  1109049413      1025684115
-./include/reiserfs     1120953071      1025684115
+./include/reiserfs     1122611350      1025684115
 ./include/setjm2.h     1109049413      1000991730
 ./include/setjmp.h     1109049413      1000991730
 ./include/stdlib.h     1109049413      1000991730
 ./include/setjm2.h     1109049413      1000991730
 ./include/setjmp.h     1109049413      1000991730
 ./include/stdlib.h     1109049413      1000991730
 ./include/swab.h       1109049413      1000991730
 ./include/types.h      1109049413      1000991730
 ./include/xfs/xfs.h    1109049413      1002101334
 ./include/swab.h       1109049413      1000991730
 ./include/types.h      1109049413      1000991730
 ./include/xfs/xfs.h    1109049413      1002101334
-./include/xfs  1120953071      1007269244
+./include/xfs  1122611350      1007269244
 ./include/yaboot.h     1109049413      1007200690
 ./include/amiga-part.h 1116558586      1116558522
 ./include/yaboot.h     1109049413      1007200690
 ./include/amiga-part.h 1116558586      1116558522
-./include/fdisk-part.h 1120952841      1120952841
-./include/partition.h  1120952841      1120952841
-./include      1120953071      1120952841
+./include/fdisk-part.h 1120953080      1120952841
+./include/partition.h  1120953080      1120952841
+./include      1122611349      1120952841
 ./lib/ctype.c  1109049413      1000991731
 ./lib/libext2fs.a      1109049413      1003927524
 ./lib/ctype.c  1109049413      1000991731
 ./lib/libext2fs.a      1109049413      1003927524
-./lib/malloc.c 1109049413      1007200690
+./lib/malloc.c 1122610545      1007200690
 ./lib/nosys.c  1109049413      1000991731
 ./lib/string.S 1109049413      1007200690
 ./lib/strtol.c 1109049413      1000991731
 ./lib/vsprintf.c       1109049413      1000991731
 ./lib/strstr.c 1119929028      1116476589
 ./lib/nosys.c  1109049413      1000991731
 ./lib/string.S 1109049413      1007200690
 ./lib/strtol.c 1109049413      1000991731
 ./lib/vsprintf.c       1109049413      1000991731
 ./lib/strstr.c 1119929028      1116476589
-./lib  1120953071      1116476589
+./lib  1122610543      1116476589
 ./man/bootstrap.8      1116558691      1000991731
 ./man/mkofboot.8       1116558691      1006348765
 ./man/ofpath.8 1116558691      1000991731
 ./man/yaboot.conf.5    1116558691      1004256691
 ./man/yabootconfig.8   1116558691      1027929577
 ./man/ybin.8   1116558691      1006348765
 ./man/bootstrap.8      1116558691      1000991731
 ./man/mkofboot.8       1116558691      1006348765
 ./man/ofpath.8 1116558691      1000991731
 ./man/yaboot.conf.5    1116558691      1004256691
 ./man/yabootconfig.8   1116558691      1027929577
 ./man/ybin.8   1116558691      1006348765
-./man/yaboot.8 1116558691      1090699543
-./man  1120953071      1116476667
+./man/yaboot.8 1121662318      1090699543
+./man  1122611350      1116476667
 ./man.patch    1116558699      1006348761
 ./second/cache.S       1120952570      1007200690
 ./second/cfg.c 1120952570      1007200690
 ./second/cmdline.c     1120952570      1032059589
 ./second/crt0.S        1120952570      1000991731
 ./man.patch    1116558699      1006348761
 ./second/cache.S       1120952570      1007200690
 ./second/cfg.c 1120952570      1007200690
 ./second/cmdline.c     1120952570      1032059589
 ./second/crt0.S        1120952570      1000991731
-./second/file.c        1120952570      1044868693
 ./second/fs.c  1120952570      1032059574
 ./second/fs_ext2.c     1120952570      1032059564
 ./second/fs_iso.c      1120952570      1007200690
 ./second/fs.c  1120952570      1032059574
 ./second/fs_ext2.c     1120952570      1032059564
 ./second/fs_iso.c      1120952570      1007200690
 ./second/md5.c 1120952570      1032059532
 ./second/prom.c        1120952570      1067937197
 ./second/setjmp.S      1120952570      1000991732
 ./second/md5.c 1120952570      1032059532
 ./second/prom.c        1120952570      1067937197
 ./second/setjmp.S      1120952570      1000991732
-./second/yaboot.c      1120952570      1032059504
-./second/fs_of.c       1120952841      1120952841
-./second/partition.c   1120952841      1120952841
-./second       1120953071      1120952841
+./second/fs_of.c       1120953080      1120952841
+./second/file.c        1122611207      1122611207
+./second/partition.c   1122611207      1122611207
+./second/yaboot.c      1122611207      1122611207
+./second       1122611350      1122611207
 ./util/elfextract.c    1109049413      1007303237
 ./util/addnote.c       1109049413      1107321884
 ./util/elfextract.c    1109049413      1007303237
 ./util/addnote.c       1109049413      1107321884
-./util 1120953071      1107321884
-./ybin/mkofboot        1120953071      1073219938
+./util 1122611350      1107321884
+./ybin/mkofboot        1122611350      1073219938
 ./ybin/ofpath  1120448537      1120448442
 ./ybin/yabootconfig    1117166139      1089576743
 ./ybin/ybin    1120448039      1120447943
 ./ybin/ofpath  1120448537      1120448442
 ./ybin/yabootconfig    1117166139      1089576743
 ./ybin/ybin    1120448039      1120447943
-./ybin 1120953071      1120448442
-.      1120953070      1120953067
+./ybin 1122611350      1120448442
+.      1122611349      1122611345
index 592cbbcb6a9589870441839efb5284c5f06eb654..7002c5d9a95c33d93976120dde9c4f58653978ef 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,22 @@
 # arch-tag: automatic-ChangeLog--erbenson@alaska.net--public/yaboot--devel--1.3
 #
 
 # arch-tag: automatic-ChangeLog--erbenson@alaska.net--public/yaboot--devel--1.3
 #
 
+2005-07-29 04:29:18 GMT        Ethan Benson <erbenson@alaska.net>      patch-84
+
+    Summary:
+      Pretend to allocate/deallocate memory correctly
+    Revision:
+      yaboot--devel--1.3--patch-84
+
+    * Pretend like we actually manage memory properly by calling free() on
+      things which were malloc()'ed or strdup()'ed.
+      (Patch from Dustin Kirkland).
+
+    modified files:
+     0arch-timestamps0 ChangeLog second/file.c second/partition.c
+     second/yaboot.c
+
+
 2005-07-09 23:51:20 GMT        Ethan Benson <erbenson@alaska.net>      patch-83
 
     Summary:
 2005-07-09 23:51:20 GMT        Ethan Benson <erbenson@alaska.net>      patch-83
 
     Summary:
index b5763a235f6d5db62ad5fb1b4c92254b89775270..ed70376be542670865c249a52e1086381418acd3 100644 (file)
@@ -78,8 +78,8 @@ parse_device_path(char *imagepath, char *defdevice, int defpart,
 
      if (!imagepath)
          return 0;
 
      if (!imagepath)
          return 0;
-     else
-         ipath = strdup(imagepath);
+     else if (!(ipath = strdup(imagepath))) 
+         return 0;
 
      if (defdevice)
          defdev = strdup(defdevice);
 
      if (defdevice)
          defdev = strdup(defdevice);
@@ -89,6 +89,8 @@ parse_device_path(char *imagepath, char *defdevice, int defpart,
               if ((ptr = strrchr(defdev, ':')) != NULL)
                    *ptr = 0; /* remove trailing : from defdevice if necessary */
          }
               if ((ptr = strrchr(defdev, ':')) != NULL)
                    *ptr = 0; /* remove trailing : from defdevice if necessary */
          }
+     } else {
+         return 0;
      }
 
      /* if there is no : then there is no filename or partition.  must
      }
 
      /* if there is no : then there is no filename or partition.  must
@@ -123,6 +125,7 @@ parse_device_path(char *imagepath, char *defdevice, int defpart,
      } else if (strlen(ipath)) {
           result->file = strdup(ipath);
      } else {
      } else if (strlen(ipath)) {
           result->file = strdup(ipath);
      } else {
+         free(defdev);
          return 0;
      }
 
          return 0;
      }
 
@@ -137,7 +140,7 @@ parse_device_path(char *imagepath, char *defdevice, int defpart,
 
      free(ipath);
      if (defdev)
 
      free(ipath);
      if (defdev)
-         free(defdev);
+          free(defdev);
      return 1;
 }
 
      return 1;
 }
 
index a95a1b25a6aa25844ee6215ee0868151a5c3b703..05823092614e1b9011fe4e2d88d26f69ebe32e40 100644 (file)
@@ -280,6 +280,10 @@ partition_amiga_lookup( const char *dev_name, prom_handle disk,
        possible = amiga_block[AMIGA_RDBLIMIT]/32 +1;
 
        used = (unsigned int *) malloc (sizeof (unsigned int) * (possible + 1));
        possible = amiga_block[AMIGA_RDBLIMIT]/32 +1;
 
        used = (unsigned int *) malloc (sizeof (unsigned int) * (possible + 1));
+       if (!used) {
+               prom_printf("Can't allocate memory\n");
+               return;
+       }
 
        for (i=0; i < possible; i++) used[i] = 0;
 
 
        for (i=0; i < possible; i++) used[i] = 0;
 
@@ -322,6 +326,8 @@ partition_amiga_lookup( const char *dev_name, prom_handle disk,
                    prom_blksize,
                    0 );
        }
                    prom_blksize,
                    0 );
        }
+       if (used) 
+               free(used);
 }
 
 struct partition_t*
 }
 
 struct partition_t*
index c31578730c7ecf353ff98b6db5f504ae12a8787b..cf920a1646f2f5ae4290c64120ba5c7934b33871 100644 (file)
@@ -435,7 +435,7 @@ bail:
      if (opened)
          file.fs->close(&file);
     
      if (opened)
          file.fs->close(&file);
     
-     if (result != 1 && conf_file)
+     if (conf_file)
          free(conf_file);
        
      return result;
          free(conf_file);
        
      return result;
@@ -1081,7 +1081,7 @@ load_elf32(struct boot_file_t *file, loadinfo_t *loadinfo)
      /* Read the rest of the Elf header... */
      if ((*(file->fs->read))(file, size, &e->e_version) < size) {
          prom_printf("\nCan't read Elf32 image header\n");
      /* Read the rest of the Elf header... */
      if ((*(file->fs->read))(file, size, &e->e_version) < size) {
          prom_printf("\nCan't read Elf32 image header\n");
-         return 0;
+         goto bail;
      }
 
      DEBUG_F("Elf32 header:\n");
      }
 
      DEBUG_F("Elf32 header:\n");
@@ -1100,24 +1100,24 @@ load_elf32(struct boot_file_t *file, loadinfo_t *loadinfo)
 
      if (e->e_phnum > MAX_HEADERS) {
          prom_printf ("Can only load kernels with one program header\n");
 
      if (e->e_phnum > MAX_HEADERS) {
          prom_printf ("Can only load kernels with one program header\n");
-         return 0;
+         goto bail;
      }
 
      ph = (Elf32_Phdr *)malloc(sizeof(Elf32_Phdr) * e->e_phnum);
      if (!ph) {
          prom_printf ("Malloc error\n");
      }
 
      ph = (Elf32_Phdr *)malloc(sizeof(Elf32_Phdr) * e->e_phnum);
      if (!ph) {
          prom_printf ("Malloc error\n");
-         return 0;
+         goto bail;
      }
 
      /* Now, we read the section header */
      if ((*(file->fs->seek))(file, e->e_phoff) != FILE_ERR_OK) {
          prom_printf ("seek error\n");
      }
 
      /* Now, we read the section header */
      if ((*(file->fs->seek))(file, e->e_phoff) != FILE_ERR_OK) {
          prom_printf ("seek error\n");
-         return 0;
+         goto bail;
      }
      if ((*(file->fs->read))(file, sizeof(Elf32_Phdr) * e->e_phnum, ph) !=
         sizeof(Elf32_Phdr) * e->e_phnum) {
          prom_printf ("read error\n");
      }
      if ((*(file->fs->read))(file, sizeof(Elf32_Phdr) * e->e_phnum, ph) !=
         sizeof(Elf32_Phdr) * e->e_phnum) {
          prom_printf ("read error\n");
-         return 0;
+         goto bail;
      }
 
      /* Scan through the program header
      }
 
      /* Scan through the program header
@@ -1144,7 +1144,7 @@ load_elf32(struct boot_file_t *file, loadinfo_t *loadinfo)
 
      if (loadinfo->memsize == 0) {
          prom_printf("Can't find a loadable segment !\n");
 
      if (loadinfo->memsize == 0) {
          prom_printf("Can't find a loadable segment !\n");
-         return 0;
+         goto bail;
      }
 
      /* leave some room (1Mb) for boot infos */
      }
 
      /* leave some room (1Mb) for boot infos */
@@ -1173,7 +1173,7 @@ load_elf32(struct boot_file_t *file, loadinfo_t *loadinfo)
      }
      if (loadinfo->base == (void *)-1) {
          prom_printf("Claim error, can't allocate kernel memory\n");
      }
      if (loadinfo->base == (void *)-1) {
          prom_printf("Claim error, can't allocate kernel memory\n");
-         return 0;
+         goto bail;
      } 
 
      DEBUG_F("After ELF parsing, load base: %p, mem_sz: 0x%08lx\n",
      } 
 
      DEBUG_F("After ELF parsing, load base: %p, mem_sz: 0x%08lx\n",
@@ -1192,13 +1192,13 @@ load_elf32(struct boot_file_t *file, loadinfo_t *loadinfo)
          if ((*(file->fs->seek))(file, p->p_offset) != FILE_ERR_OK) {
               prom_printf ("Seek error\n");
               prom_release(loadinfo->base, loadinfo->memsize);
          if ((*(file->fs->seek))(file, p->p_offset) != FILE_ERR_OK) {
               prom_printf ("Seek error\n");
               prom_release(loadinfo->base, loadinfo->memsize);
-              return 0;
+              goto bail;
          }
          offset = p->p_vaddr - loadinfo->load_loc;
          if ((*(file->fs->read))(file, p->p_filesz, loadinfo->base+offset) != p->p_filesz) {
               prom_printf ("Read failed\n");
               prom_release(loadinfo->base, loadinfo->memsize);
          }
          offset = p->p_vaddr - loadinfo->load_loc;
          if ((*(file->fs->read))(file, p->p_filesz, loadinfo->base+offset) != p->p_filesz) {
               prom_printf ("Read failed\n");
               prom_release(loadinfo->base, loadinfo->memsize);
-              return 0;
+              goto bail;
          }
      }
 
          }
      }
 
@@ -1206,6 +1206,11 @@ load_elf32(struct boot_file_t *file, loadinfo_t *loadinfo)
     
      /* Return success at loading the Elf32 kernel */
      return 1;
     
      /* Return success at loading the Elf32 kernel */
      return 1;
+
+bail:
+     if (ph)
+       free(ph);
+     return 0;
 }
 
 static int
 }
 
 static int
@@ -1220,7 +1225,7 @@ load_elf64(struct boot_file_t *file, loadinfo_t *loadinfo)
      /* Read the rest of the Elf header... */
      if ((*(file->fs->read))(file, size, &e->e_version) < size) {
          prom_printf("\nCan't read Elf64 image header\n");
      /* Read the rest of the Elf header... */
      if ((*(file->fs->read))(file, size, &e->e_version) < size) {
          prom_printf("\nCan't read Elf64 image header\n");
-         return 0;
+         goto bail;
      }
 
      DEBUG_F("Elf64 header:\n");
      }
 
      DEBUG_F("Elf64 header:\n");
@@ -1239,24 +1244,24 @@ load_elf64(struct boot_file_t *file, loadinfo_t *loadinfo)
 
      if (e->e_phnum > MAX_HEADERS) {
          prom_printf ("Can only load kernels with one program header\n");
 
      if (e->e_phnum > MAX_HEADERS) {
          prom_printf ("Can only load kernels with one program header\n");
-         return 0;
+         goto bail;
      }
 
      ph = (Elf64_Phdr *)malloc(sizeof(Elf64_Phdr) * e->e_phnum);
      if (!ph) {
          prom_printf ("Malloc error\n");
      }
 
      ph = (Elf64_Phdr *)malloc(sizeof(Elf64_Phdr) * e->e_phnum);
      if (!ph) {
          prom_printf ("Malloc error\n");
-         return 0;
+         goto bail;
      }
 
      /* Now, we read the section header */
      if ((*(file->fs->seek))(file, e->e_phoff) != FILE_ERR_OK) {
          prom_printf ("Seek error\n");
      }
 
      /* Now, we read the section header */
      if ((*(file->fs->seek))(file, e->e_phoff) != FILE_ERR_OK) {
          prom_printf ("Seek error\n");
-         return 0;
+         goto bail;
      }
      if ((*(file->fs->read))(file, sizeof(Elf64_Phdr) * e->e_phnum, ph) !=
         sizeof(Elf64_Phdr) * e->e_phnum) {
          prom_printf ("Read error\n");
      }
      if ((*(file->fs->read))(file, sizeof(Elf64_Phdr) * e->e_phnum, ph) !=
         sizeof(Elf64_Phdr) * e->e_phnum) {
          prom_printf ("Read error\n");
-         return 0;
+         goto bail;
      }
 
      /* Scan through the program header
      }
 
      /* Scan through the program header
@@ -1283,7 +1288,7 @@ load_elf64(struct boot_file_t *file, loadinfo_t *loadinfo)
 
      if (loadinfo->memsize == 0) {
          prom_printf("Can't find a loadable segment !\n");
 
      if (loadinfo->memsize == 0) {
          prom_printf("Can't find a loadable segment !\n");
-         return 0;
+         goto bail;
      }
 
      /* leave some room (1Mb) for boot infos */
      }
 
      /* leave some room (1Mb) for boot infos */
@@ -1312,7 +1317,7 @@ load_elf64(struct boot_file_t *file, loadinfo_t *loadinfo)
      }
      if (loadinfo->base == (void *)-1) {
          prom_printf("Claim error, can't allocate kernel memory\n");
      }
      if (loadinfo->base == (void *)-1) {
          prom_printf("Claim error, can't allocate kernel memory\n");
-         return 0;
+         goto bail;
      } 
 
      DEBUG_F("After ELF parsing, load base: %p, mem_sz: 0x%08lx\n",
      } 
 
      DEBUG_F("After ELF parsing, load base: %p, mem_sz: 0x%08lx\n",
@@ -1331,13 +1336,13 @@ load_elf64(struct boot_file_t *file, loadinfo_t *loadinfo)
          if ((*(file->fs->seek))(file, p->p_offset) != FILE_ERR_OK) {
               prom_printf ("Seek error\n");
               prom_release(loadinfo->base, loadinfo->memsize);
          if ((*(file->fs->seek))(file, p->p_offset) != FILE_ERR_OK) {
               prom_printf ("Seek error\n");
               prom_release(loadinfo->base, loadinfo->memsize);
-              return 0;
+              goto bail;
          }
          offset = p->p_vaddr - loadinfo->load_loc;
          if ((*(file->fs->read))(file, p->p_filesz, loadinfo->base+offset) != p->p_filesz) {
               prom_printf ("Read failed\n");
               prom_release(loadinfo->base, loadinfo->memsize);
          }
          offset = p->p_vaddr - loadinfo->load_loc;
          if ((*(file->fs->read))(file, p->p_filesz, loadinfo->base+offset) != p->p_filesz) {
               prom_printf ("Read failed\n");
               prom_release(loadinfo->base, loadinfo->memsize);
-              return 0;
+              goto bail;
          }
      }
 
          }
      }
 
@@ -1345,6 +1350,11 @@ load_elf64(struct boot_file_t *file, loadinfo_t *loadinfo)
     
      /* Return success at loading the Elf64 kernel */
      return 1;
     
      /* Return success at loading the Elf64 kernel */
      return 1;
+
+bail:
+     if (ph)
+       free(ph);
+     return 0;
 }
 
 static int
 }
 
 static int
@@ -1521,11 +1531,13 @@ yaboot_main(void)
               if ((ptype != NULL) && (strcmp(ptype, "Apple_Bootstrap")))
                    prom_printf("\nWARNING: Bootstrap partition type is wrong: \"%s\"\n"
                                "         type should be: \"Apple_Bootstrap\"\n\n", ptype);
               if ((ptype != NULL) && (strcmp(ptype, "Apple_Bootstrap")))
                    prom_printf("\nWARNING: Bootstrap partition type is wrong: \"%s\"\n"
                                "         type should be: \"Apple_Bootstrap\"\n\n", ptype);
+              if (ptype)
+                   free(ptype);
          }
      }
 
      yaboot_text_ui();
          }
      }
 
      yaboot_text_ui();
-       
+
      prom_printf("Bye.\n");
      return 0;
 }
      prom_printf("Bye.\n");
      return 0;
 }