Skip to content

Commit 3c3bfb8

Browse files
Tetsuo Handahdeller
authored andcommitted
fbdev: fbcon: release buffer when fbcon_do_set_font() failed
syzbot is reporting memory leak at fbcon_do_set_font() [1], for commit a5a9230 ("fbdev: fbcon: Properly revert changes when vc_resize() failed") missed that the buffer might be newly allocated by fbcon_set_font(). Link: https://syzkaller.appspot.com/bug?extid=25bdb7b1703639abd498 [1] Reported-by: syzbot <[email protected]> Signed-off-by: Tetsuo Handa <[email protected]> Tested-by: syzbot <[email protected]> Fixes: a5a9230 ("fbdev: fbcon: Properly revert changes when vc_resize() failed") CC: [email protected] # 5.15+ Signed-off-by: Helge Deller <[email protected]>
1 parent b20a558 commit 3c3bfb8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/video/fbdev/core/fbcon.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2450,7 +2450,8 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount,
24502450

24512451
if (userfont) {
24522452
p->userfont = old_userfont;
2453-
REFCOUNT(data)--;
2453+
if (--REFCOUNT(data) == 0)
2454+
kfree(data - FONT_EXTRA_WORDS * sizeof(int));
24542455
}
24552456

24562457
vc->vc_font.width = old_width;

0 commit comments

Comments
 (0)