From c021aef9b0c49625ecf56a105d6b32dae5b5fa1b Mon Sep 17 00:00:00 2001 From: CTCaer Date: Wed, 27 Mar 2024 09:36:08 +0200 Subject: [PATCH] fss: save fss0 for being able to free it if error Also do not free secmon/kernel in case it's from fss --- bootloader/hos/fss.c | 2 ++ bootloader/hos/hos.c | 9 +++------ bootloader/hos/hos.h | 1 + 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bootloader/hos/fss.c b/bootloader/hos/fss.c index 213df25..6bb66f0 100644 --- a/bootloader/hos/fss.c +++ b/bootloader/hos/fss.c @@ -209,6 +209,8 @@ int parse_fss(launch_ctxt_t *ctxt, const char *path) gfx_printf("Done!\n"); f_close(&fp); + ctxt->fss0 = fss; + // Update r2p if needed. _fss_update_r2p(); diff --git a/bootloader/hos/hos.c b/bootloader/hos/hos.c index f7ab52a..d63e0b7 100644 --- a/bootloader/hos/hos.c +++ b/bootloader/hos/hos.c @@ -694,12 +694,12 @@ out: static void _free_launch_components(launch_ctxt_t *ctxt) { + // Free the malloc'ed guaranteed addresses. + free(ctxt->fss0); free(ctxt->keyblob); free(ctxt->pkg1); free(ctxt->pkg2); free(ctxt->warmboot); - free(ctxt->secmon); - free(ctxt->kernel); free(ctxt->kip1_patches); } @@ -1035,7 +1035,6 @@ int hos_launch(ini_sec_t *cfg) { _hos_crit_error("SD Card is exFAT but installed HOS driver\nonly supports FAT32!"); - _free_launch_components(&ctxt); goto error; } } @@ -1056,10 +1055,7 @@ int hos_launch(ini_sec_t *cfg) } if (emmc_patch_failed || !(btn_wait() & BTN_POWER)) - { - _free_launch_components(&ctxt); goto error; // MUST stop here, because if user requests 'nogc' but it's not applied, their GC controller gets updated! - } } // Rebuild and encrypt package2. @@ -1179,6 +1175,7 @@ int hos_launch(ini_sec_t *cfg) bpmp_halt(); error: + _free_launch_components(&ctxt); emmc_end(); EPRINTF("\nFailed to launch HOS!"); diff --git a/bootloader/hos/hos.h b/bootloader/hos/hos.h index be2f76d..f27728c 100644 --- a/bootloader/hos/hos.h +++ b/bootloader/hos/hos.h @@ -109,6 +109,7 @@ typedef struct _launch_ctxt_t bool stock; bool emummc_forced; + void *fss0; u32 fss0_hosver; bool atmosphere;