diff options
| author | Thomas Zimmermann <tzimmermann@suse.de> | 2026-03-09 15:14:52 +0100 |
|---|---|---|
| committer | Helge Deller <deller@gmx.de> | 2026-03-09 15:47:21 +0100 |
| commit | 1e3c49aa03fbfeea595ca0c9a4ebaf1e9cc078af (patch) | |
| tree | ce76d079bb41f55c51f21b6a27da9991c6de3893 /drivers/video | |
| parent | 1de371b1f1b02dc82da598f9707089229699a604 (diff) | |
lib/fonts: Compare font data for equality with font_data_is_equal()
Add font_data_is_equal() and update consoles to use it.
Font data is equal if it has the same size and contains the same values
on all bytes. Only fbcon uses a crc32 checksum. If set in both operands
the checksums have to be equal.
The new helper also guarantees to not compare internal fonts against
fonts from user space. Internal fonts cannot be ref-counted, so making
them equal to user-space fonts with the same byte sequence results in
undefined behavior.
The test only compares data buffers. Their interpretation is up each
console. Therefore remove a width test in fbcon_set_font().
v3:
- rebase onto font_data_{get,put}()
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Helge Deller <deller@gmx.de>
Diffstat (limited to 'drivers/video')
| -rw-r--r-- | drivers/video/console/newport_con.c | 4 | ||||
| -rw-r--r-- | drivers/video/fbdev/core/fbcon.c | 7 |
2 files changed, 2 insertions, 9 deletions
diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c index dbbb787fc46e..db0228bce00e 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -529,9 +529,7 @@ static int newport_set_font(int unit, const struct console_font *op, /* check if font is already used by other console */ for (i = 0; i < MAX_NR_CONSOLES; i++) { - if (font_data[i] != FONT_DATA - && font_data_size(font_data[i]) == size - && !memcmp(font_data[i], new_data, size)) { + if (font_data_is_equal(font_data[i], new_data)) { font_data_put(new_data); /* current font is the same as the new one */ if (i == unit) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index ac59480c98cb..00255ac92e42 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2540,13 +2540,8 @@ static int fbcon_set_font(struct vc_data *vc, const struct console_font *font, FNTSUM(new_data) = csum; /* Check if the same font is on some other console already */ for (i = first_fb_vc; i <= last_fb_vc; i++) { - struct vc_data *tmp = vc_cons[i].d; - if (fb_display[i].fontdata && - FNTSUM(fb_display[i].fontdata) == csum && - font_data_size(fb_display[i].fontdata) == size && - tmp->vc_font.width == w && - !memcmp(fb_display[i].fontdata, new_data, size)) { + font_data_is_equal(fb_display[i].fontdata, new_data)) { font_data_get(fb_display[i].fontdata); font_data_put(new_data); new_data = fb_display[i].fontdata; |
