From 94d818db907d34dea1063ef0d0e0045fe88b0541 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Wed, 2 Dec 2020 04:05:16 -0800 Subject: [PATCH] kern: fix KHandleTable null deref in ipc --- .../include/mesosphere/kern_k_handle_table.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_handle_table.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_handle_table.hpp index 838f58028..5cbbaf489 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_handle_table.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_handle_table.hpp @@ -166,8 +166,10 @@ namespace ams::kern { KScopedSpinLock lk(this->lock); KAutoObject *obj = this->GetObjectImpl(handle); - if (obj->DynamicCast() != nullptr) { - return nullptr; + if (AMS_LIKELY(obj != nullptr)) { + if (AMS_UNLIKELY(obj->DynamicCast() != nullptr)) { + return nullptr; + } } return obj;