Skip to contentSkip to conversation

vt: fix potential dual con_driver register for conswitchp

PATCH Superseded Wang YanQing 1 participant 1 message Dec 29, 2013 TTY layer and serial drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vt: fix potential dual con_driver register for conswitchp

We should check whether conswitchp is registered before add it to registered_con_driver in con_init, or it will cause dual con_driver register for conswitchp.

Although I haven't met it in reality, but I think it could happen for Embeded devices, who register platform con_driver earlier than call con_init.

---
 drivers/tty/vt/vt.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/tty/vt/vt.c +2 -0
index edcd6b8..3de4504 100644
@@ -2876,6 +2876,8 @@ static int __init con_init(void)
 	for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
 		struct con_driver *con_driver = &registered_con_driver[i];
 
+		if (con_driver->con == conswitchp)
+			break;
 		if (con_driver->con == NULL) {
 			con_driver->con = conswitchp;
 			con_driver->desc = display_desc;
Signature · 1 line
1.8.3.4.8.g69490f3.dirty