From 1d4cbb92f2f2c1702fe5843c6ece471f53d2b2d9 Mon Sep 17 00:00:00 2001
From: bunnei <bunneidev@gmail.com>
Date: Wed, 28 Oct 2020 17:17:38 -0700
Subject: [PATCH] service: hle: nvflinger: Fix potential shutdown crash when
 GPU is destroyed.

---
 src/core/hle/service/nvflinger/nvflinger.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp
index c64673dba..44aa2bdae 100644
--- a/src/core/hle/service/nvflinger/nvflinger.cpp
+++ b/src/core/hle/service/nvflinger/nvflinger.cpp
@@ -242,6 +242,10 @@ void NVFlinger::Compose() {
 
         const auto& igbp_buffer = buffer->get().igbp_buffer;
 
+        if (!system.IsPoweredOn()) {
+            return; // We are likely shutting down
+        }
+
         auto& gpu = system.GPU();
         const auto& multi_fence = buffer->get().multi_fence;
         guard->unlock();