mirror of
https://github.com/ipxe/ipxe
synced 2026-01-24 13:13:42 +03:00
[image] Use image replacement when executing extracted images
Use image_replace() to transfer execution to the extracted image, rather than calling image_exec() directly. This allows the original archive image to be freed immediately if it was marked as an automatically freeable image (e.g. via "chain --autofree"). In particular, this ensures that in the case of an archive image containing another archive image (such as an EFI zboot kernel wrapper image containing a gzip-compressed kernel image), the intermediate extracted image will be freed as early as possible, since extracted images are always marked as automatically freeable. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -119,9 +119,14 @@ int image_extract_exec ( struct image *image ) {
|
||||
/* Set auto-unregister flag */
|
||||
extracted->flags |= IMAGE_AUTO_UNREGISTER;
|
||||
|
||||
/* Tail-recurse into extracted image */
|
||||
return image_exec ( extracted );
|
||||
/* Replace current image */
|
||||
if ( ( rc = image_replace ( extracted ) ) != 0 )
|
||||
goto err_replace;
|
||||
|
||||
/* Return to allow replacement image to be executed */
|
||||
return 0;
|
||||
|
||||
err_replace:
|
||||
err_set_cmdline:
|
||||
unregister_image ( extracted );
|
||||
err_extract:
|
||||
|
||||
Reference in New Issue
Block a user