Skip to contentSkip to conversation

vt: fix potential dual con_driver register for conswitchp

PATCH In review Wang YanQing 2 participants 2 messages Dec 30, 2013 – Jan 9, 2014 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 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.

---
Change v1-v2:
1: if conswitchp is registered, then
make it become "system driver" by
change value of first,last,flag.

 drivers/tty/vt/vt.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/tty/vt/vt.c +6 -0
index 9adb4e0..b786129 100644
@@ -2876,6 +2876,12 @@ 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) {
+			con_driver->flag = CON_DRIVER_FLAG_INIT;
+			con_driver->first = 0;
+			con_driver->last = MAX_NR_CONSOLES - 1;
+			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
maintainer
#1 lore raw
Quoted 7 lines · Wang YanQing

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.

Does that happen on those systems? Let's not add code that's never going to be use, and is not needed, right?

thanks,

greg k-h