diff --git a/power/aidl/vts/VtsHalPowerTargetTest.cpp b/power/aidl/vts/VtsHalPowerTargetTest.cpp index 53fcef1a41..db777c5e78 100644 --- a/power/aidl/vts/VtsHalPowerTargetTest.cpp +++ b/power/aidl/vts/VtsHalPowerTargetTest.cpp @@ -175,8 +175,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: