From 727c2a7dd80589e99b6061f362cf5f1f4d5a84d7 Mon Sep 17 00:00:00 2001 From: Samuli Piippo Date: Mon, 8 May 2017 08:47:27 +0300 Subject: [PATCH] fbcon: Compare variable screen info instead of modes (FIX) Previous commit changed behavior, so that when trying to match a mode to a variable screen info structure, the mode was first converted to a variable screen structure rather than the variable screen info structure to a mode. However, when new mode was being added to the modelist, matching was still being done using mode structure. This could cause situation, where existing mode would match when comparing with mode structure, but not when compared using variable screen info structure. This would eventually result in a NULL pointer dereference in fbcon_switch. Fix the issue by using the variable screen info structure also when adding new mode to the modelist. --- drivers/video/modedb.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/video/modedb.c b/drivers/video/modedb.c index 12dadab..e5093cf 100644 --- a/drivers/video/modedb.c +++ b/drivers/video/modedb.c @@ -2190,13 +2190,14 @@ int fb_add_videomode(const struct fb_videomode *mode, struct list_head *head) { struct list_head *pos; struct fb_modelist *modelist; - struct fb_videomode *m; + struct fb_var_screeninfo v1, v2; int found = 0; + fb_videomode_to_var(&v1, mode); list_for_each(pos, head) { modelist = list_entry(pos, struct fb_modelist, list); - m = &modelist->mode; - if (fb_mode_is_equal(m, mode)) { + fb_videomode_to_var(&v2, &modelist->mode); + if (fb_var_is_equal(&v1, &v2)) { found = 1; break; }