gterm: Prevent memory leak gterm_init() failure
diff --git a/common/lib/gterm.c b/common/lib/gterm.c
index c496ad98..d7551742 100644
--- a/common/lib/gterm.c
+++ b/common/lib/gterm.c
@@ -776,15 +776,15 @@ no_load_font:;
font_scale_x, font_scale_y,
margin);
- if (term == NULL) {
- return false;
- }
-
pmm_free(font, FONT_MAX);
if (bg_canvas != NULL) {
pmm_free(bg_canvas, bg_canvas_size);
}
+ if (term == NULL) {
+ return false;
+ }
+
if (serial) {
term->cols = term->cols > 80 ? 80 : term->cols;
term->rows = term->rows > 24 ? 24 : term->rows;
