fss: save fss0 for being able to free it if error

Also do not free secmon/kernel in case it's from fss
This commit is contained in:
CTCaer 2024-03-27 09:36:08 +02:00
parent 622f7124ac
commit c021aef9b0
3 changed files with 6 additions and 6 deletions

View File

@ -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();

View File

@ -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,11 +1055,8 @@ 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.
pkg2_build_encrypt((void *)PKG2_LOAD_ADDR, &ctxt, &kip1_info, is_exo);
@ -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!");

View File

@ -109,6 +109,7 @@ typedef struct _launch_ctxt_t
bool stock;
bool emummc_forced;
void *fss0;
u32 fss0_hosver;
bool atmosphere;