Re: [PATCH v3 4/4] crypto: ccp: Fix memory leak in SEV INIT_EX path

From: Herbert Xu

Date: Fri Jul 03 2026 - 02:21:04 EST


On Tue, Jun 02, 2026 at 03:36:35PM -0700, Atish Patra wrote:
> From: Atish Patra <atishp@xxxxxxxx>
>
> allocated pages in _init_ext_path are never freed and sev_init_ex_buffer
> is left pointing at the leaked memory in case of any failures during the
> function..
>
> Fix by adding an error path that frees the pages and clears
> sev_init_ex_buffer. Make sure we only free the memory if the failure
> happens before the conversion. Otherwise, we may end up trying to free
> up converted pages in case of reclaim failure. rmp_mark_pages_firmware
> failures should be rare enough to avoid more code complexity to track
> down which pages were reclaimed/leaked vs which are not.
>
> Fixes: 7364a6fbca45 ("crypto: ccp: Handle non-volatile INIT_EX data when SNP is enabled")
>
> Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
> Reviewed-by: Tom Lendacky <thomas.lendacky@xxxxxxx>
> Signed-off-by: Atish Patra <atishp@xxxxxxxx>
> ---
> drivers/crypto/ccp/sev-dev.c | 17 ++++++++++++++---
> 1 file changed, 14 insertions(+), 3 deletions(-)

Acked-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt