Fix illegal access to deallocated memory.

When deallocating context with LUKS2 reencryption handle
we access data device structure after being free'd.
This commit is contained in:
Ondrej Kozina
2019-08-08 14:46:01 +02:00
parent a23e1cf729
commit 54d757a4c7

View File

@@ -2918,12 +2918,13 @@ void crypt_free(struct crypt_device *cd)
dm_backend_exit(cd);
crypt_free_volume_key(cd->volume_key);
crypt_free_type(cd);
device_free(cd, cd->device);
device_free(cd, cd->metadata_device);
free(CONST_CAST(void*)cd->pbkdf.type);
free(CONST_CAST(void*)cd->pbkdf.hash);
crypt_free_type(cd);
/* Some structures can contain keys (TCRYPT), wipe it */
crypt_memzero(cd, sizeof(*cd));