mirror of
https://git.citron-emu.org/citron/emulator
synced 2025-12-19 18:53:32 +00:00
fix(nvdrv): prevent infinite loop when SMMU address space is exhausted
Fix crash in PinHandle when SMMU allocation fails and unmap queue is empty. Previously, the code would log an error and continue looping indefinitely, causing log spam and eventual crash. Now it returns 0 to fail gracefully. Also fix incorrect handle check on line 219 - should check freeHandleDesc instead of handle_description. Signed-off-by: Zephyron <zephyron@citron-emu.org>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
|
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
|
||||||
// SPDX-FileCopyrightText: 2022 Skyline Team and Contributors
|
// SPDX-FileCopyrightText: 2022 Skyline Team and Contributors
|
||||||
|
// SPDX-FileCopyrightText: 2025 citron Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
@@ -216,10 +217,12 @@ DAddr NvMap::PinHandle(NvMap::Handle::Id handle, bool low_area_pin) {
|
|||||||
// Handles in the unmap queue are guaranteed not to be pinned so don't bother
|
// Handles in the unmap queue are guaranteed not to be pinned so don't bother
|
||||||
// checking if they are before unmapping
|
// checking if they are before unmapping
|
||||||
std::scoped_lock freeLock(freeHandleDesc->mutex);
|
std::scoped_lock freeLock(freeHandleDesc->mutex);
|
||||||
if (handle_description->d_address)
|
if (freeHandleDesc->d_address)
|
||||||
UnmapHandle(*freeHandleDesc);
|
UnmapHandle(*freeHandleDesc);
|
||||||
} else {
|
} else {
|
||||||
LOG_CRITICAL(Service_NVDRV, "Ran out of SMMU address space!");
|
LOG_CRITICAL(Service_NVDRV, "Ran out of SMMU address space!");
|
||||||
|
// Break out of the loop to prevent infinite spinning when no handles can be freed
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user