Skip to content

Commit c66f0be

Browse files
Dan Carpentergregkh
authored andcommitted
crypto: iaa - Fix potential use after free bug
[ Upstream commit e0d3b84 ] The free_device_compression_mode(iaa_device, device_mode) function frees "device_mode" but it iss passed to iaa_compression_modes[i]->free() a few lines later resulting in a use after free. The good news is that, so far as I can tell, nothing implements the ->free() function and the use after free happens in dead code. But, with this fix, when something does implement it, we'll be ready. :) Fixes: b190447 ("crypto: iaa - Add compression mode management along with fixed mode") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 70bae36 commit c66f0be

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/crypto/intel/iaa/iaa_crypto_main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,10 +495,10 @@ static void remove_device_compression_modes(struct iaa_device *iaa_device)
495495
if (!device_mode)
496496
continue;
497497

498-
free_device_compression_mode(iaa_device, device_mode);
499-
iaa_device->compression_modes[i] = NULL;
500498
if (iaa_compression_modes[i]->free)
501499
iaa_compression_modes[i]->free(device_mode);
500+
free_device_compression_mode(iaa_device, device_mode);
501+
iaa_device->compression_modes[i] = NULL;
502502
}
503503
}
504504

0 commit comments

Comments
 (0)