svn commit: r356040 - in stable: 11/sys/dev/vt 12/sys/dev/vt
Kyle Evans
kevans at FreeBSD.org
Mon Dec 23 20:19:24 UTC 2019
Author: kevans
Date: Mon Dec 23 20:19:23 2019
New Revision: 356040
URL: https://svnweb.freebsd.org/changeset/base/356040
Log:
MFC r355935: vt: fix post-boot keyboard attachment
With absolutely no keyboards attached and no kbdmux in kernel, we descend
down this error path. 0 is a valid keyboard index, so leaving
vd->vd_keyboard at 0 when there's no keyboard found is objectively wrong as
later attachment of a keyboard will fail -- it gets index 0, and vt thinks
it's already using that keyboard.
This is decidedly the corniest of corner cases, but it's easy enough to get
correct that we should do so.
Tested in a kernel without atkbdc, atkbd, psm, kbdmux, ukbd, hyperv then
loading ukbd post-boot and attaching a usb keyboard.
Modified:
stable/12/sys/dev/vt/vt_core.c
Directory Properties:
stable/12/ (props changed)
Changes in other areas also in this revision:
Modified:
stable/11/sys/dev/vt/vt_core.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/12/sys/dev/vt/vt_core.c
==============================================================================
--- stable/12/sys/dev/vt/vt_core.c Mon Dec 23 20:18:05 2019 (r356039)
+++ stable/12/sys/dev/vt/vt_core.c Mon Dec 23 20:19:23 2019 (r356040)
@@ -1039,6 +1039,13 @@ vt_allocate_keyboard(struct vt_device *vd)
DPRINTF(20, "%s: no kbdmux allocated\n", __func__);
idx0 = kbd_allocate("*", -1, vd, vt_kbdevent, vd);
if (idx0 < 0) {
+ /*
+ * We don't have a keyboard yet, so we must invalidate
+ * vd->vd_keyboard so that later keyboard attachment can
+ * succeed. Any value >= 0 can accidentally match a
+ * keyboard.
+ */
+ vd->vd_keyboard = -1;
DPRINTF(10, "%s: No keyboard found.\n", __func__);
return (-1);
}
More information about the svn-src-stable
mailing list