grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Re: Revision 2136 breaks two-disk configuarion


From: Pavel Roskin
Subject: [PATCH] Re: Revision 2136 breaks two-disk configuarion
Date: Mon, 27 Apr 2009 21:37:52 -0400

On Mon, 2009-04-27 at 18:26 -0400, Pavel Roskin wrote:

> It's entirely possible that the problem is elsewhere.  But I have no
> experience debugging memory problems in GRUB, so it will take time
> before I find out.

Done!  disk->partition should not be copied by reference.  This patch
fixes the broken magic problem.  The issue with mixing device and disk
functions could be addressed separately.

ChangeLog:
        disk/fs_uuid.c (grub_fs_uuid_open): Allocate memory to copy
        parent's partition, don't copy it by reference, as it gets freed
        on close.
---

 disk/fs_uuid.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)


diff --git a/disk/fs_uuid.c b/disk/fs_uuid.c
index 9d83bb8..9636ce9 100644
--- a/disk/fs_uuid.c
+++ b/disk/fs_uuid.c
@@ -25,6 +25,7 @@
 #include <grub/types.h>
 
 #include <grub/fs.h>
+#include <grub/partition.h>
 
 static grub_device_t
 search_fs_uuid (const char *key, unsigned long *count)
@@ -88,7 +89,16 @@ grub_fs_uuid_open (const char *name, grub_disk_t disk)
 
   disk->total_sectors = dev->disk->total_sectors;
   disk->has_partitions = 0;
-  disk->partition = dev->disk->partition;
+  if (dev->disk->partition)
+    {
+      disk->partition = grub_malloc (sizeof (*disk->partition));
+      if (disk->partition)
+       grub_memcpy (disk->partition, dev->disk->partition,
+                    sizeof (*disk->partition));
+    }
+  else
+    disk->partition = NULL;
+
   disk->data = dev->disk;
 
   return GRUB_ERR_NONE;

-- 
Regards,
Pavel Roskin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]