]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
grub-core/disk/geli.c: fix memory leaks in error paths
authorAndrei Borzenkov <arvidjaar@gmail.com>
Fri, 28 Nov 2014 19:23:30 +0000 (22:23 +0300)
committerAndrei Borzenkov <arvidjaar@gmail.com>
Fri, 28 Nov 2014 19:23:30 +0000 (22:23 +0300)
CID: 73813, 73710

grub-core/disk/geli.c

index 9025c9d460798ef3a568aace4b6f0531c5baaa52..17273416f27ec34dcd34885f1ca24d79d1e0098f 100644 (file)
@@ -332,19 +332,29 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
     {
       secondary_cipher = grub_crypto_cipher_open (ciph);
       if (!secondary_cipher)
-       return NULL;
+       {
+         grub_crypto_cipher_close (cipher);
+         return NULL;
+       }
+
     }
 
   if (grub_le_to_cpu16 (header.keylen) > 1024)
     {
       grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid keysize %d",
                  grub_le_to_cpu16 (header.keylen));
+      grub_crypto_cipher_close (cipher);
+      grub_crypto_cipher_close (secondary_cipher);
       return NULL;
     }
 
   newdev = grub_zalloc (sizeof (struct grub_cryptodisk));
   if (!newdev)
-    return NULL;
+    {
+      grub_crypto_cipher_close (cipher);
+      grub_crypto_cipher_close (secondary_cipher);
+      return NULL;
+    }
   newdev->cipher = cipher;
   newdev->secondary_cipher = secondary_cipher;
   newdev->offset = 0;