Skip to content

Commit

Permalink
efi/libstub: Free correct pointer on failure
Browse files Browse the repository at this point in the history
cmdline_ptr is an out parameter, which is not allocated by the function
itself, and likely points into the caller's stack.

cmdline refers to the pool allocation that should be freed when cleaning
up after a failure, so pass this instead to free_pool().

Fixes: 42c8ea3 ("efi: libstub: Factor out EFI stub entrypoint ...")
Cc: <stable@vger.kernel.org>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
  • Loading branch information
Ard Biesheuvel committed Nov 15, 2024
1 parent 63971b0 commit 06d39d7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/firmware/efi/libstub/efi-stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ efi_status_t efi_handle_cmdline(efi_loaded_image_t *image, char **cmdline_ptr)
return EFI_SUCCESS;

fail_free_cmdline:
efi_bs_call(free_pool, cmdline_ptr);
efi_bs_call(free_pool, cmdline);
return status;
}

Expand Down

0 comments on commit 06d39d7

Please sign in to comment.