dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Thomas Zimmermann" <tzimmermann@suse.de>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 6/6] fbcon: Handle characters with no glyph defined in a consistent way
Date: Fri, 20 Nov 2026 12:28:59 +0000	[thread overview]
Message-ID: <sashiko-outbox-225142@kernel.org> (raw)
In-Reply-To: <20261120115215.52092-7-tzimmermann@suse.de>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] fbcon: wrong font buffer in bit_putcs_aligned() and
  bit_putcs_unaligned()
- [Medium] fbcon: fallback lookup in ccw_cursor() repeats c & charmask
  instead of NUL
--

commit 87130bf587571fed7c1353d5789cd5ab5b6c495b
Author: Thomas Zimmermann <tzimmermann@suse.de>

fbcon: Handle characters with no glyph defined in a consistent way

This commit checks the return value of font_data_glyph_buf() for NULL
across fbcon drawing functions, falling back to the '\0' glyph or
skipping the character when undefined.

> diff --git a/drivers/video/fbdev/core/bitblit.c b/drivers/video/fbdev/core/bitblit.c
> index c28329466f051..cf3adc46aaa9a 100644
> --- a/drivers/video/fbdev/core/bitblit.c
> +++ b/drivers/video/fbdev/core/bitblit.c
> @@ -81,7 +81,6 @@ static inline void bit_putcs_aligned(struct vc_data *vc, struct fb_info *info,
>  				     unsigned char *buf, u8 *dst)
>  {
>  	u16 charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
> -	unsigned int charcnt = vc->vc_font.charcount;
>  	u32 idx = vc->vc_font.width >> 3;
>  	struct fbcon_par *par = info->fbcon_par;
>  	u32 s_pitch = font_glyph_pitch(s_width);
> @@ -90,9 +89,12 @@ static inline void bit_putcs_aligned(struct vc_data *vc, struct fb_info *info,
>  	while (cnt--) {
>  		u16 ch = scr_readw(s++) & charmask;
>  
> -		if (ch >= charcnt)
> -			ch = 0;
>  		src = font_data_glyph_buf(par->p->fontdata, s_width, s_vpitch, ch);
> +		if (!src) {
> +			src = font_data_glyph_buf(par->rotated.buf, s_width, s_vpitch, '\0');
> +			if (!src)
> +				goto next_char;
> +		}
>  
>  		if (attr) {
>  			update_attr(buf, src, attr, vc);
> @@ -105,7 +107,7 @@ static inline void bit_putcs_aligned(struct vc_data *vc, struct fb_info *info,
>  		else
>  			fb_pad_aligned_buffer(dst, d_pitch, src, idx,
>  					      image->height);
> -
> +next_char:
>  		dst += s_pitch;
>  	}
>  
> @@ -120,7 +122,6 @@ static inline void bit_putcs_unaligned(struct vc_data *vc,
>  				       unsigned char *buf, u8 *dst)
>  {
>  	u16 charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
> -	unsigned int charcnt = vc->vc_font.charcount;
>  	u32 shift_low = 0, mod = vc->vc_font.width % 8;
>  	u32 shift_high = 8;
>  	u32 idx = vc->vc_font.width >> 3;
> @@ -131,9 +132,12 @@ static inline void bit_putcs_unaligned(struct vc_data *vc,
>  	while (cnt--) {
>  		u16 ch = scr_readw(s++) & charmask;
>  
> -		if (ch >= charcnt)
> -			ch = 0;
>  		src = font_data_glyph_buf(par->p->fontdata, s_width, s_vpitch, ch);
> +		if (!src) {
> +			src = font_data_glyph_buf(par->rotated.buf, s_width, s_vpitch, '\0');
> +			if (!src)
> +				goto next_char;
> +		}

[Severity: High]
Should the fallback lookups in bit_putcs_aligned() and
bit_putcs_unaligned() pass par->p->fontdata instead of par->rotated.buf?

par->rotated is only defined when CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is
enabled, so builds without it fail to compile.  When rotation support is
compiled in, par->rotated.buf is NULL on an unrotated console, causing
font_data_glyph_buf() -> font_data_num_glyphs() -> font_data_size() to
dereference a NULL pointer whenever an out-of-range character index is
drawn.

[ ... ]

> diff --git a/drivers/video/fbdev/core/fbcon_ccw.c b/drivers/video/fbdev/core/fbcon_ccw.c
> index 9da6c0e41e7a2..cbaa75fc1cc14 100644
> --- a/drivers/video/fbdev/core/fbcon_ccw.c
> +++ b/drivers/video/fbdev/core/fbcon_ccw.c
[ ... ]
> @@ -246,6 +251,11 @@ static void ccw_cursor(struct vc_data *vc, struct fb_info *info, bool enable,
>   	c = scr_readw((u16 *) vc->vc_pos);
>  	attribute = get_attribute(info, c);
>  	src = font_data_glyph_buf(par->rotated.buf, width, vpitch, c & charmask);
> +	if (!src) {
> +		src = font_data_glyph_buf(par->rotated.buf, width, vpitch, c & charmask);
> +		if (!src)
> +			return;
> +	}

[Severity: Medium]
Should the fallback call in ccw_cursor() look up '\0' instead of
c & charmask again?  Repeating c & charmask always returns NULL when the
first lookup fails, so the cursor is skipped instead of falling back to
the '\0' glyph.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120115215.52092-1-tzimmermann@suse.de?part=6

      reply	other threads:[~2026-11-20 12:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 11:49 [PATCH v2 0/6] fbcon: Clean up glyph handling on redraws Thomas Zimmermann
2026-11-20 11:49 ` [PATCH v2 1/6] fbcon: Use unsigned char for glyph data Thomas Zimmermann
2026-11-21 17:37   ` Helge Deller
2026-11-20 11:49 ` [PATCH v2 2/6] lib/fonts: Provide internal helpers for allocating font_data_t Thomas Zimmermann
2026-11-20 11:49 ` [PATCH v2 3/6] lib/fonts, fbcon: Use font_data_t for rotated fonts Thomas Zimmermann
2026-11-20 12:01   ` sashiko-bot
2026-11-20 11:49 ` [PATCH v2 4/6] fbcon: Refactor size calculation for cursor buffers Thomas Zimmermann
2026-11-20 11:49 ` [PATCH v2 5/6] fbcon: Look up glyphs using the font interface Thomas Zimmermann
2026-11-20 12:22   ` sashiko-bot
2026-11-20 11:49 ` [PATCH v2 6/6] fbcon: Handle characters with no glyph defined in a consistent way Thomas Zimmermann
2026-11-20 12:28   ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-225142@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox