[PATCH master 2/3] common: pe: fix crash when pe_load was not called
Ahmad Fatoum
a.fatoum at pengutronix.de
Fri Apr 4 08:55:20 PDT 2025
pe_close is the counterpart to pe_open. pe->code is set to non-NULL
outside pe_open by pe_load, so we should check for NULL before
attempting to free the SDRAM region.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
common/pe.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/common/pe.c b/common/pe.c
index 65d456a2c332..fd99761bddfd 100644
--- a/common/pe.c
+++ b/common/pe.c
@@ -373,7 +373,8 @@ int pe_load(struct pe_image *pe)
void pe_close(struct pe_image *pe)
{
- release_sdram_region(pe->code);
+ if (pe->code)
+ release_sdram_region(pe->code);
free(pe->bin);
free(pe);
}
--
2.39.5
More information about the barebox
mailing list