Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/nvidia-modeset/src/nvkms.c
Original file line number Diff line number Diff line change
Expand Up @@ -5307,6 +5307,8 @@ void nvKmsClose(void *pOpenVoid)
}


static NvBool revokeInProgress = FALSE;

/*
*Frees all references to a device
*/
Expand All @@ -5316,6 +5318,21 @@ void nvRevokeDevice(NVDevEvoPtr pDevEvo)
return;
}

/*
* FreeDeviceReference() can call back into nvRevokeDevice() through
* ReleaseModesetOwnership() -> RestoreConsole() if the core channel
* cannot be reallocated. The nested call would call
* FreeDeviceReference() again for the pOpenDev that is being freed,
* dropping its device reference twice, so the device could be freed
* while other clients still use it. The outer loop frees all remaining
* references, so just return.
*/
if (revokeInProgress) {
return;
}

revokeInProgress = TRUE;

struct NvKmsPerOpen *pOpen;

nvListForEachEntry(pOpen, &perOpenIoctlList, perOpenIoctlListEntry) {
Expand All @@ -5330,6 +5347,8 @@ void nvRevokeDevice(NVDevEvoPtr pDevEvo)
}
FreeDeviceReference(pOpen, pOpenDev);
}

revokeInProgress = FALSE;
}

/*!
Expand Down