diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index 66167830fefd..67c1c29e8960 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -1058,8 +1058,12 @@ static const char *fbcon_startup(void) vc->vc_font.height = font->height; vc->vc_font.data = (void *)(p->fontdata = font->data); vc->vc_font.charcount = 256; /* FIXME Need to support more fonts */ + BUG_ON(p->userfont != is_dyn_font(vc->vc_font.data)); + pr_info("%s fbcon_display=%px vc->vc_font.data=%px\n", __func__, p, vc->vc_font.data); } else { p->fontdata = vc->vc_font.data; + BUG_ON(p->userfont != is_dyn_font(vc->vc_font.data)); + pr_info("%s fbcon_display=%px vc->vc_font.data=%px\n", __func__, p, vc->vc_font.data); } cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres); @@ -1125,6 +1129,8 @@ static void fbcon_init(struct vc_data *vc, int init) if (p->userfont) REFCOUNT(p->fontdata)++; + BUG_ON(p->userfont != is_dyn_font(vc->vc_font.data)); + pr_info("%s fbcon_display=%px vc->vc_font.data=%px\n", __func__, p, vc->vc_font.data); } else { const struct font_desc *font = NULL; @@ -1138,6 +1144,8 @@ static void fbcon_init(struct vc_data *vc, int init) vc->vc_font.data = (void *)(p->fontdata = font->data); vc->vc_font.charcount = 256; /* FIXME Need to support more fonts */ + BUG_ON(p->userfont != is_dyn_font(vc->vc_font.data)); + pr_info("%s fbcon_display=%px vc->vc_font.data=%px\n", __func__, p, vc->vc_font.data); } } @@ -1444,6 +1452,8 @@ static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var, vc->vc_font.width = (*default_mode)->vc_font.width; vc->vc_font.height = (*default_mode)->vc_font.height; p->userfont = t->userfont; + BUG_ON(p->userfont != is_dyn_font(vc->vc_font.data)); + pr_info("%s fbcon_display=%px vc->vc_font.data=%px\n", __func__, p, vc->vc_font.data); if (p->userfont) REFCOUNT(p->fontdata)++; } @@ -2203,6 +2213,8 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width, struct fb_var_screeninfo var = info->var; int x_diff, y_diff, virt_w, virt_h, virt_fw, virt_fh; + pr_info("%s ops=%px ops->p=%px fbcon_display=%px vc->vc_font.data=%px\n", __func__, + ops, ops->p, p, vc->vc_font.data); if (ops->p && ops->p->userfont && FNTSIZE(vc->vc_font.data)) { int size; int pitch = PITCH(vc->vc_font.width); @@ -2613,6 +2625,8 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, vc->vc_font.data = (void *)(p->fontdata = data); if ((p->userfont = userfont)) REFCOUNT(data)++; + BUG_ON(p->userfont != is_dyn_font(vc->vc_font.data)); + pr_info("%s fbcon_display=%px vc->vc_font.data=%px\n", __func__, p, vc->vc_font.data); vc->vc_font.width = w; vc->vc_font.height = h; if (vc->vc_hi_font_mask && cnt == 256) diff --git a/include/linux/font.h b/include/linux/font.h index 51b91c8b69d5..9a4f6d96f75f 100644 --- a/include/linux/font.h +++ b/include/linux/font.h @@ -51,6 +51,10 @@ extern const struct font_desc font_vga_8x8, extern const struct font_desc *find_font(const char *name); +/* Check if font data seems to be dynamic */ + +extern bool is_dyn_font(const void *data); + /* Get the default font for a specific screen size */ extern const struct font_desc *get_default_font(int xres, int yres, diff --git a/lib/fonts/fonts.c b/lib/fonts/fonts.c index e7258d8c252b..777c19d299bf 100644 --- a/lib/fonts/fonts.c +++ b/lib/fonts/fonts.c @@ -19,6 +19,7 @@ #include #endif #include +#include static const struct font_desc *fonts[] = { #ifdef CONFIG_FONT_8x8 @@ -88,6 +89,22 @@ const struct font_desc *find_font(const char *name) } EXPORT_SYMBOL(find_font); +/** + * is_dyn_font - check if font data seems to be dynamic + * @data: font data to examine + * + * Returns true if @data seems to be dynamic, false otherwise. + */ +bool is_dyn_font(const void *data) +{ + unsigned int i; + + for (i = 0; i < num_fonts; i++) + if (fonts[i]->data == data) + return false; + return !ZERO_OR_NULL_PTR(data) && !IS_ERR(data); +} +EXPORT_SYMBOL(is_dyn_font); /** * get_default_font - get default font