grub-core/disk/geli.c: fix memory leaks in error paths

CID: 73813, 73710
This commit is contained in:
Andrei Borzenkov 2014-11-28 22:23:30 +03:00
parent 740c08ed2f
commit bbbcb791ed
1 changed files with 12 additions and 2 deletions

View 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;