grub-core/disk/geli.c: fix memory leaks in error paths
CID: 73813, 73710
This commit is contained in:
parent
740c08ed2f
commit
bbbcb791ed
1 changed files with 12 additions and 2 deletions
|
@ -332,19 +332,29 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
|
||||||
{
|
{
|
||||||
secondary_cipher = grub_crypto_cipher_open (ciph);
|
secondary_cipher = grub_crypto_cipher_open (ciph);
|
||||||
if (!secondary_cipher)
|
if (!secondary_cipher)
|
||||||
return NULL;
|
{
|
||||||
|
grub_crypto_cipher_close (cipher);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (grub_le_to_cpu16 (header.keylen) > 1024)
|
if (grub_le_to_cpu16 (header.keylen) > 1024)
|
||||||
{
|
{
|
||||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid keysize %d",
|
grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid keysize %d",
|
||||||
grub_le_to_cpu16 (header.keylen));
|
grub_le_to_cpu16 (header.keylen));
|
||||||
|
grub_crypto_cipher_close (cipher);
|
||||||
|
grub_crypto_cipher_close (secondary_cipher);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
newdev = grub_zalloc (sizeof (struct grub_cryptodisk));
|
newdev = grub_zalloc (sizeof (struct grub_cryptodisk));
|
||||||
if (!newdev)
|
if (!newdev)
|
||||||
return NULL;
|
{
|
||||||
|
grub_crypto_cipher_close (cipher);
|
||||||
|
grub_crypto_cipher_close (secondary_cipher);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
newdev->cipher = cipher;
|
newdev->cipher = cipher;
|
||||||
newdev->secondary_cipher = secondary_cipher;
|
newdev->secondary_cipher = secondary_cipher;
|
||||||
newdev->offset = 0;
|
newdev->offset = 0;
|
||||||
|
|
Loading…
Reference in a new issue