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 <[email protected]> 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/[email protected]?part=6
