sun_mouse: remove entry from vuidMouseList in DEVICE_CLOSE

Originally written by fei.feng@oracle.com to fix Oracle Bug 17429216:
"global vuidMouseList should not keep info for removed mouse device"

"During the testing for bug#17251473, I often see the mouse hang in X.
 By debugging, I get that there seems something wrong in mouse_drv.so -
 when a mouse is disconnected, the global vuidMouseList does not cleanup
 the mouse's recorded info. So if a newly inserted mouse allocates a
 input info pInfo which happens to have the same memory address as
 previous pInfo, the driver would go wrong."

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
This commit is contained in:
Alan Coopersmith
2022-11-09 17:01:47 -08:00
parent cd5b383c3f
commit 52073e2edc

View File

@@ -742,8 +742,21 @@ vuidMouseProc(DeviceIntPtr pPointer, int what)
}
break;
case DEVICE_OFF:
case DEVICE_CLOSE:
if (vuidMouseList == pVuidMse)
vuidMouseList = vuidMouseList->next;
else {
VuidMsePtr m = vuidMouseList;
while ((m != NULL) && (m->next != pVuidMse)) {
m = m->next;
}
if (m != NULL)
m->next = pVuidMse->next;
}
/* fallthrough */
case DEVICE_OFF:
if (pInfo->fd != -1) {
if (pVuidMse->strmod) {
SYSCALL(i = ioctl(pInfo->fd, I_POP, pVuidMse->strmod));