[2050] 2009-03-29 Vladimir Serbinenko <[email protected]>

Vladimir Serbinenko <[email protected]>
Newsgroups gmane.comp.boot-loaders.grub.cvs
Message-ID <[email protected]>
Revision: 2050
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=2050
Author:   phcoder
Date:     2009-03-29 21:21:19 +0000 (Sun, 29 Mar 2009)
Log Message:
-----------
2009-03-29  Vladimir Serbinenko  <[email protected]>

      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

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/disk/scsi.c
    trunk/grub2/kern/disk.c

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog	2009-03-29 19:52:35 UTC (rev 2049)
+++ trunk/grub2/ChangeLog	2009-03-29 21:21:19 UTC (rev 2050)
@@ -1,3 +1,11 @@
+2009-03-29  Vladimir Serbinenko  <[email protected]>
+
+      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  <[email protected]>
 
 	* loader/i386/linux.c (grub_cmd_linux): Parse "vga=" parameter and

Modified: trunk/grub2/disk/scsi.c
===================================================================
--- trunk/grub2/disk/scsi.c	2009-03-29 19:52:35 UTC (rev 2049)
+++ trunk/grub2/disk/scsi.c	2009-03-29 21:21:19 UTC (rev 2050)
@@ -255,6 +255,7 @@
 	  scsi->name = grub_strdup (name);
 	  if (! scsi->name)
 	    {
+	      grub_free (scsi);
 	      return grub_errno;
 	    }
 
@@ -263,6 +264,7 @@
 	  err = grub_scsi_inquiry (scsi);
 	  if (err)
 	    {
+	      grub_free (scsi);
 	      grub_dprintf ("scsi", "inquiry failed\n");
 	      return grub_errno;
 	    }
@@ -275,6 +277,7 @@
 	  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 @@
 	  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_free (scsi);
+
   return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a SCSI disk");
 }
 

Modified: trunk/grub2/kern/disk.c
===================================================================
--- trunk/grub2/kern/disk.c	2009-03-29 19:52:35 UTC (rev 2049)
+++ trunk/grub2/kern/disk.c	2009-03-29 21:21:19 UTC (rev 2050)
@@ -158,10 +158,13 @@
   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)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.