git: cf58c8667cfd - main - loader.efi: Clear the zstd stream pointer in zstd_fini()

From: Olivier Cochard <olivier_at_FreeBSD.org>
Date: Sun, 15 Nov 2026 12:59:34 UTC
The branch main has been updated by olivier:

URL: https://cgit.FreeBSD.org/src/commit/?id=cf58c8667cfd1fd4e866a0609918d6e44960dd6e

commit cf58c8667cfd1fd4e866a0609918d6e44960dd6e
Author:     Olivier Cochard <olivier@FreeBSD.org>
AuthorDate: 2026-11-12 11:27:45 +0000
Commit:     Olivier Cochard <olivier@FreeBSD.org>
CommitDate: 2026-11-15 12:50:35 +0000

    loader.efi: Clear the zstd stream pointer in zstd_fini()
    
    do_download_ramdisk() calls decomp_fini() a second time to free the buffer when
    it gives up after a finished download, so zstd freed its strem twice and libsa
    libsa panicked. Clear the pointer like xz_fini().
    
    Reported by:    llm-postcr
    Reviewed by:    imp
    Approved by:    imp
    Fixes:          afee781523e4 ("loader.efi: Recognize new memdisk=<url> and memcd=<url> options")
    Sponsored by:   Netflix
---
 stand/efi/loader/decompress.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/stand/efi/loader/decompress.c b/stand/efi/loader/decompress.c
index c90634037260..704b5288123d 100644
--- a/stand/efi/loader/decompress.c
+++ b/stand/efi/loader/decompress.c
@@ -426,6 +426,7 @@ static void
 zstd_fini(decomp_state *dctx, bool flush)
 {
 	ZSTD_freeDStream(dctx->zstdstrm);
+	dctx->zstdstrm = NULL;
 	if (!flush)
 		return;
 	free_buffer(dctx);