summaryrefslogtreecommitdiffstats
path: root/meta-tegra-extras/recipes/linux/linux-tegra/0001-fbcon-Compare-variable-screen-info-instead-of-modes-.patch
blob: c700e0e47c3342474325f5027221d5767da5f1b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
From 727c2a7dd80589e99b6061f362cf5f1f4d5a84d7 Mon Sep 17 00:00:00 2001
From: Samuli Piippo <samuli.piippo@qt.io>
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;
 		}