Skip to content

Commit

Permalink
x86, efi: Only close open files in error path
Browse files Browse the repository at this point in the history
The loop at the 'close_handles' label in handle_ramdisks() should be
using 'i', which represents the number of initrd files that were
successfully opened, not 'nr_initrds' which is the number of initrd=
arguments passed on the command line.

Currently, if we execute the loop to close all file handles and we
failed to open any initrds we'll try to call the close function on a
garbage pointer, causing the machine to hang.

Cc: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Link: http://lkml.kernel.org/r/1331907517-3985-2-git-send-email-matt@console-pimps.org
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
  • Loading branch information
Matt Fleming authored and H. Peter Anvin committed Jun 1, 2012
1 parent fb21aff commit 30dc0d0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arch/x86/boot/compressed/eboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ static efi_status_t handle_ramdisks(efi_loaded_image_t *image,
low_free(initrd_total, initrd_addr);

close_handles:
for (k = j; k < nr_initrds; k++)
for (k = j; k < i; k++)
efi_call_phys1(fh->close, initrds[k].handle);
free_initrds:
efi_call_phys1(sys_table->boottime->free_pool, initrds);
Expand Down

0 comments on commit 30dc0d0

Please sign in to comment.