]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* util/getroot.c (grub_util_get_dm_node_linear_info): Fix memory leak.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 29 Jan 2012 20:49:44 +0000 (21:49 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 29 Jan 2012 20:49:44 +0000 (21:49 +0100)
* grub-core/disk/cryptodisk.c (cryptodisk_cleanup): Disable for
now to avoid double free.
* grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_dev): Rename to
hostdisk.
* include/grub/disk.h (grub_disk_dev_id): New id HOSTDISK.
* util/grub-probe.c (escape_of_path): Always return a new copy.
(print_full_name): Escape path.
(probe): Don't call grub_util_devname_to_ofpath on NULL.
Fix hints on abstractions.

ChangeLog
grub-core/disk/cryptodisk.c
grub-core/kern/emu/hostdisk.c
include/grub/disk.h
util/getroot.c
util/grub-probe.c

index 48f4530596e2ff95833f76350006621619fb0d64..943ed0fad85011fe41c5be7b62d8c6bbe16b3381 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2012-01-29  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * util/getroot.c (grub_util_get_dm_node_linear_info): Fix memory leak.
+       * grub-core/disk/cryptodisk.c (cryptodisk_cleanup): Disable for
+       now to avoid double free.
+       * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_dev): Rename to
+       hostdisk.
+       * include/grub/disk.h (grub_disk_dev_id): New id HOSTDISK.
+       * util/grub-probe.c (escape_of_path): Always return a new copy.
+       (print_full_name): Escape path.
+       (probe): Don't call grub_util_devname_to_ofpath on NULL.
+       Fix hints on abstractions.
+
 2012-01-29  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * util/grub-mkconfig_lib.in (prepare_grub_to_access_device):
index 8be2e21cfe7ce0c038cb741a63b57557e13b5ad1..7d63f3e4620e4358abf82135e87cd9d2b63b6cf9 100644 (file)
@@ -658,6 +658,7 @@ grub_cryptodisk_memberlist (grub_disk_t disk)
 static void
 cryptodisk_cleanup (void)
 {
+#if 0
   grub_cryptodisk_t dev = cryptodisk_list;
   grub_cryptodisk_t tmp;
 
@@ -671,6 +672,7 @@ cryptodisk_cleanup (void)
       grub_free (dev);
       dev = tmp;
     }
+#endif
 }
 
 grub_err_t
index 1a39e9c561bd63dd8f943c52033e8815db723af0..704911e121e8f15b933812741f577e6e37c55300 100644 (file)
@@ -1107,8 +1107,8 @@ grub_util_biosdisk_close (struct grub_disk *disk)
 
 static struct grub_disk_dev grub_util_biosdisk_dev =
   {
-    .name = "biosdisk",
-    .id = GRUB_DISK_DEVICE_BIOSDISK_ID,
+    .name = "hostdisk",
+    .id = GRUB_DISK_DEVICE_HOSTDISK_ID,
     .iterate = grub_util_biosdisk_iterate,
     .open = grub_util_biosdisk_open,
     .close = grub_util_biosdisk_close,
index 27d74788df2a3e6b5b7c418e55df912a472b468b..ca46f031e712f8f771f5c79d0c48994d76067ce2 100644 (file)
@@ -40,6 +40,7 @@ enum grub_disk_dev_id
     GRUB_DISK_DEVICE_SCSI_ID,
     GRUB_DISK_DEVICE_CRYPTODISK_ID,
     GRUB_DISK_DEVICE_ARCDISK_ID,
+    GRUB_DISK_DEVICE_HOSTDISK_ID,
   };
 
 struct grub_disk;
index 6b773767c892b2fb7e87b9af542aa9b53f6d3400..cae7611ab1c0b63bebf8e5500585ddc861cfe021 100644 (file)
@@ -1246,33 +1246,48 @@ grub_util_get_dm_node_linear_info (const char *dev,
     return 0;
   
   if (!dm_task_set_name(dmt, dev))
-    return 0;
+    {
+      dm_task_destroy (dmt);
+      return 0;
+    }
   dm_task_no_open_count(dmt);
   if (!dm_task_run(dmt))
-    return 0;
+    {
+      dm_task_destroy (dmt);
+      return 0;
+    }
   next = dm_get_next_target(dmt, next, &start, &length,
                            &target, &params);
   if (grub_strcmp (target, "linear") != 0)
-    return 0;
+    {
+      dm_task_destroy (dmt);
+      return 0;
+    }
   major = grub_strtoul (params, &ptr, 10);
   if (grub_errno)
     {
+      dm_task_destroy (dmt);
       grub_errno = GRUB_ERR_NONE;
       return 0;
     }
   if (*ptr != ':')
-    return 0;
+    {
+      dm_task_destroy (dmt);
+      return 0;
+    }
   ptr++;
   minor = grub_strtoul (ptr, 0, 10);
   if (grub_errno)
     {
       grub_errno = GRUB_ERR_NONE;
+      dm_task_destroy (dmt);
       return 0;
     }
   if (maj)
     *maj = major;
   if (min)
     *min = minor;
+  dm_task_destroy (dmt);
   return 1;
 }
 #endif
index bb75d938ccf11de7ce6e632d4121eb846fa610e5..17edff6ce9c5c47dac0254fd111f385a3a1c0025 100644 (file)
@@ -149,7 +149,7 @@ escape_of_path (const char *orig_path)
   const char *p;
 
   if (!strchr (orig_path, ','))
-    return (char *) orig_path;
+    return (char *) xstrdup (orig_path);
 
   new_path = xmalloc (strlen (orig_path) * 2 + sizeof ("ieee1275/"));
 
@@ -259,14 +259,16 @@ guess_baremetal_drive (const char *orig_path)
 static void
 print_full_name (const char *drive, grub_device_t dev)
 {
+  char *dname = escape_of_path (drive);
   if (dev->disk->partition)
     {
       char *pname = grub_partition_get_name (dev->disk->partition);
-      printf ("%s,%s", drive, pname);
+      printf ("%s,%s", dname, pname);
       free (pname);
     }
   else
-    printf ("%s", drive);
+    printf ("%s", dname);
+  free (dname);
 } 
 
 static void
@@ -363,17 +365,15 @@ probe (const char *path, char *device_name)
   if (print == PRINT_HINT_STR)
     {
       const char *osdev = grub_util_biosdisk_get_osdev (dev->disk);
-      const char *orig_path = grub_util_devname_to_ofpath (osdev);
+      const char *ofpath = osdev ? grub_util_devname_to_ofpath (osdev) : 0;
       char *biosname, *bare, *efi;
       const char *map;
 
-      if (orig_path)
+      if (ofpath)
        {
-         char *ofpath = escape_of_path (orig_path);
          printf ("--hint-ieee1275='");
          print_full_name (ofpath, dev);
          printf ("' ");
-         free (ofpath);
        }
 
       biosname = guess_bios_drive (device_name);
@@ -417,6 +417,16 @@ probe (const char *path, char *device_name)
       goto end;
     }
 
+  if ((print == PRINT_COMPATIBILITY_HINT || print == PRINT_BIOS_HINT
+       || print == PRINT_IEEE1275_HINT || print == PRINT_BAREMETAL_HINT
+       || print == PRINT_EFI_HINT || print == PRINT_ARC_HINT)
+      && dev->disk->dev->id != GRUB_DISK_DEVICE_HOSTDISK_ID)
+    {
+      print_full_name (dev->disk->name, dev);
+      printf ("\n");
+      goto end;
+    }
+
   if (print == PRINT_COMPATIBILITY_HINT)
     {
       const char *map;
@@ -449,8 +459,7 @@ probe (const char *path, char *device_name)
   if (print == PRINT_IEEE1275_HINT)
     {
       const char *osdev = grub_util_biosdisk_get_osdev (dev->disk);
-      const char *orig_path = grub_util_devname_to_ofpath (osdev);
-      char *ofpath = escape_of_path (orig_path);
+      const char *ofpath = grub_util_devname_to_ofpath (osdev);
       const char *map;
 
       map = grub_util_biosdisk_get_compatibility_hint (dev->disk);
@@ -460,11 +469,13 @@ probe (const char *path, char *device_name)
          print_full_name (map, dev);
        }
 
-      printf (" ");
-      print_full_name (ofpath, dev);
+      if (ofpath)
+       {
+         printf (" ");
+         print_full_name (ofpath, dev);
+       }
 
       printf ("\n");
-      free (ofpath);
       goto end;
     }
   if (print == PRINT_EFI_HINT)