]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
diskfilter_make_raid: more memory leaks in failure path
authorAndrei Borzenkov <arvidjaar@gmail.com>
Sun, 15 Feb 2015 07:10:03 +0000 (10:10 +0300)
committerAndrei Borzenkov <arvidjaar@gmail.com>
Sun, 15 Feb 2015 07:14:07 +0000 (10:14 +0300)
grub-core/disk/diskfilter.c

index 1b7464d74c8b0a892d187ceef2d916f97be3307f..c4f6678b612acb34390a000ec0c20728de4480e6 100644 (file)
@@ -1031,7 +1031,10 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
        if (n == 1)
          n = (layout >> 8) & 0xFF;
        if (n == 0)
-         return NULL;
+         {
+           grub_free (uuid);
+           return NULL;
+         }
 
        totsize = grub_divmod64 (nmemb * disk_size, n, 0);
       }
@@ -1045,6 +1048,7 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
       break;
 
     default:
+      grub_free (uuid);
       return NULL;
     }
 
@@ -1067,7 +1071,10 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
     }
   array = grub_zalloc (sizeof (*array));
   if (!array)
-    return NULL;
+    {
+      grub_free (uuid);
+      return NULL;
+    }
   array->uuid = uuid;
   array->uuid_len = uuidlen;
   if (name)
@@ -1166,6 +1173,8 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
       grub_free (array->pvs);
       array->pvs = pv;
     }
+  grub_free (array->name);
+  grub_free (array->uuid);
   grub_free (array);
   return NULL;
 }