[1889] 2008-10-29 Guillem Jover <[email protected]>

Robert Millan <[email protected]>
Newsgroups gmane.comp.boot-loaders.grub.cvs
Message-ID <[email protected]>
Revision: 1889
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=1889
Author:   robertmh
Date:     2008-10-29 19:24:11 +0000 (Wed, 29 Oct 2008)

Log Message:
-----------
2008-10-29  Guillem Jover <[email protected]>

        * disk/lvm.c (grub_lvm_scan_device): Fix error recovery by delaying the
        addition of objects until the code is not going to be able to fail.

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/disk/lvm.c

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog	2008-10-29 19:22:13 UTC (rev 1888)
+++ trunk/grub2/ChangeLog	2008-10-29 19:24:11 UTC (rev 1889)
@@ -1,5 +1,10 @@
 2008-10-29  Guillem Jover <[email protected]>
 
+	* disk/lvm.c (grub_lvm_scan_device): Fix error recovery by delaying the
+	addition of objects until the code is not going to be able to fail.
+
+2008-10-29  Guillem Jover <[email protected]>
+
 	* disk/lvm.c (grub_lvm_scan_device): Fix possible NULL value handling
 	(add a missing NULL check, and correct them by moving the pointer
 	operations after the actual check).

Modified: trunk/grub2/disk/lvm.c
===================================================================
--- trunk/grub2/disk/lvm.c	2008-10-29 19:22:13 UTC (rev 1888)
+++ trunk/grub2/disk/lvm.c	2008-10-29 19:24:11 UTC (rev 1889)
@@ -356,8 +356,6 @@
 
       vg->lvs = NULL;
       vg->pvs = NULL;
-      vg->next = vg_list;
-      vg_list = vg;
 
       p = grub_strstr (p, "physical_volumes {");
       if (p)
@@ -395,14 +393,15 @@
 	      pv->start = grub_lvm_getvalue (&p, "pe_start = ");
 	      if (p == NULL)
 		goto pvs_fail;
-	      pv->disk = NULL;
-	      pv->next = vg->pvs;
-	      vg->pvs = pv;
 	      
 	      p = grub_strchr (p, '}');
 	      if (p == NULL)
 		goto pvs_fail;
 	      p++;
+
+	      pv->disk = NULL;
+	      pv->next = vg->pvs;
+	      vg->pvs = pv;
 	      
 	      continue;
 	    pvs_fail:
@@ -531,16 +530,16 @@
 		  goto fail4;
 		}
 
-	      lv->number = lv_count++;
-	      lv->vg = vg;
-	      lv->next = vg->lvs;
-	      vg->lvs = lv;
-	      
 	      p = grub_strchr (p, '}');
 	      if (p == NULL)
 		goto lvs_fail;
 	      p += 3;
 	      
+	      lv->number = lv_count++;
+	      lv->vg = vg;
+	      lv->next = vg->lvs;
+	      vg->lvs = lv;
+
 	      continue;
 	    lvs_fail:
 	      grub_free (lv->name);
@@ -548,6 +547,9 @@
 	      goto fail4;
 	    }
 	}
+
+	vg->next = vg_list;
+	vg_list = vg;
     }
   else
     {
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.