video: console: Fix default font selection
authorOndrej Jirman <megi@xff.cz>
Thu, 25 May 2023 12:17:15 +0000 (14:17 +0200)
committerAnatolij Gustschin <agust@denx.de>
Fri, 14 Jul 2023 16:07:31 +0000 (18:07 +0200)
Some callers expect to call this with NULL font name to select the
default font (eg. boot/scene.c). Without handling the NULL condition
U-Boot crashes instead of displaying a bootflow GUI menu.

Signed-off-by: Ondrej Jirman <megi@xff.cz>
Cc: Anatolij Gustschin <agust@denx.de>
drivers/video/console_core.c

index 1f93b1b..b5d0e3d 100644 (file)
@@ -201,6 +201,12 @@ int console_simple_select_font(struct udevice *dev, const char *name, uint size)
 {
        struct video_fontdata *font;
 
+       if (!name) {
+               if (fonts->name)
+                       console_set_font(dev, fonts);
+               return 0;
+       }
+
        for (font = fonts; font->name; font++) {
                if (!strcmp(name, font->name)) {
                        console_set_font(dev, font);