diff --git a/power/aidl/vts/VtsHalPowerTargetTest.cpp b/power/aidl/vts/VtsHalPowerTargetTest.cpp index 67efa7a90e..939deb2966 100644 --- a/power/aidl/vts/VtsHalPowerTargetTest.cpp +++ b/power/aidl/vts/VtsHalPowerTargetTest.cpp @@ -180,8 +180,12 @@ class FMQAidl : public PowerAidl { ASSERT_NE(mEventFlag, nullptr); } virtual void TearDown() { - mSession->close(); - ASSERT_TRUE(power->closeSessionChannel(getpid(), getuid()).isOk()); + if (mSession) { + mSession->close(); + if (mChannel->isValid()) { + ASSERT_TRUE(power->closeSessionChannel(getpid(), getuid()).isOk()); + } + } } protected: