]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2009-03-29 Vladimir Serbinenko <phcoder@gmail.com>
authorphcoder <phcoder@localhost>
Sun, 29 Mar 2009 21:21:19 +0000 (21:21 +0000)
committerphcoder <phcoder@localhost>
Sun, 29 Mar 2009 21:21:19 +0000 (21:21 +0000)
      Leak fixes

      * kern/disk.c (grub_disk_cache_store): Invalidate previous cache
      in case of collision
      * disk/scsi.c (grub_scsi_open): free scsi in case of error

ChangeLog
disk/scsi.c
kern/disk.c

index 0afef50997a44e55a29fe28c4abc33ff6798a732..95071010380b2c20b92e6ec8754b882d98fbad2b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-03-29  Vladimir Serbinenko  <phcoder@gmail.com>
+
+      Leak fixes
+
+      * kern/disk.c (grub_disk_cache_store): Invalidate previous cache
+      in case of collision
+      * disk/scsi.c (grub_scsi_open): free scsi in case of error
+
 2009-03-29  Robert Millan  <rmh@aybabtu.com>
 
        * loader/i386/linux.c (grub_cmd_linux): Parse "vga=" parameter and
index 75b92b4090c63d5e79d59b796a3874ee12182dc6..319d8d6722e8e2e27542a6bfe971aaf507a0ea05 100644 (file)
@@ -255,6 +255,7 @@ grub_scsi_open (const char *name, grub_disk_t disk)
          scsi->name = grub_strdup (name);
          if (! scsi->name)
            {
+             grub_free (scsi);
              return grub_errno;
            }
 
@@ -263,6 +264,7 @@ grub_scsi_open (const char *name, grub_disk_t disk)
          err = grub_scsi_inquiry (scsi);
          if (err)
            {
+             grub_free (scsi);
              grub_dprintf ("scsi", "inquiry failed\n");
              return grub_errno;
            }
@@ -275,6 +277,7 @@ grub_scsi_open (const char *name, grub_disk_t disk)
          if (scsi->devtype != grub_scsi_devtype_direct
              && scsi->devtype != grub_scsi_devtype_cdrom)
            {
+             grub_free (scsi);
              return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
                                 "unknown SCSI device");
            }
@@ -287,6 +290,7 @@ grub_scsi_open (const char *name, grub_disk_t disk)
          err = grub_scsi_read_capacity (scsi);
          if (err)
            {
+             grub_free (scsi);
              grub_dprintf ("scsi", "READ CAPACITY failed\n");
              return grub_errno;
            }
@@ -303,6 +307,8 @@ grub_scsi_open (const char *name, grub_disk_t disk)
        }
     }
 
+  grub_free (scsi);
+
   return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a SCSI disk");
 }
 
index 4ee03e0d95dffc641f1fcb26d6b4dab6a209ef98..8a92989ade74e93cba9fdb28759415ce699eced9 100644 (file)
@@ -158,10 +158,13 @@ grub_disk_cache_store (unsigned long dev_id, unsigned long disk_id,
   unsigned index;
   struct grub_disk_cache *cache;
   
-  grub_disk_cache_invalidate (dev_id, disk_id, sector);
-  
   index = grub_disk_cache_get_index (dev_id, disk_id, sector);
   cache = grub_disk_cache_table + index;
+  cache->lock = 1;
+  grub_free (cache->data);
+  cache->data = 0;
+  cache->lock = 0;
   
   cache->data = grub_malloc (GRUB_DISK_SECTOR_SIZE << GRUB_DISK_CACHE_BITS);
   if (! cache->data)