fs/zfs/zfscrypt.c: fix memory leaks.

Found by: Coverity scan.
This commit is contained in:
Andrei Borzenkov 2015-01-27 21:12:19 +03:00
parent 3db4f05a10
commit fa13e60527

View file

@ -354,6 +354,7 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key,
if (err) if (err)
{ {
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
grub_crypto_cipher_close (cipher);
continue; continue;
} }
@ -362,6 +363,7 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key,
if (err) if (err)
{ {
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
grub_crypto_cipher_close (cipher);
continue; continue;
} }
@ -372,6 +374,7 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key,
{ {
grub_dprintf ("zfs", "key loading failed\n"); grub_dprintf ("zfs", "key loading failed\n");
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
grub_crypto_cipher_close (cipher);
continue; continue;
} }
@ -381,12 +384,14 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key,
{ {
grub_dprintf ("zfs", "key loading failed\n"); grub_dprintf ("zfs", "key loading failed\n");
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
grub_crypto_cipher_close (cipher);
continue; continue;
} }
ret = grub_crypto_cipher_open (GRUB_CIPHER_AES); ret = grub_crypto_cipher_open (GRUB_CIPHER_AES);
if (!ret) if (!ret)
{ {
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
grub_crypto_cipher_close (cipher);
continue; continue;
} }
err = grub_crypto_cipher_set_key (ret, decrypted, keylen); err = grub_crypto_cipher_set_key (ret, decrypted, keylen);
@ -394,8 +399,10 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key,
{ {
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
grub_crypto_cipher_close (ret); grub_crypto_cipher_close (ret);
grub_crypto_cipher_close (cipher);
continue; continue;
} }
grub_crypto_cipher_close (cipher);
return ret; return ret;
} }
return NULL; return NULL;