sm8350-common: gps: Add NULL check before object access

Correct the NULL check code block and add NULL check before
object access.

Change-Id: Ic41b781b41fb4e21bbff8801d500a41a6d7219d0
CRs-fixed: 3084543
This commit is contained in:
Madhanraj Chelladurai 2023-09-01 18:22:06 +02:00 committed by FlowerSea0208
parent f09da84023
commit a20d1da042

View File

@ -184,16 +184,19 @@ BatteryListenerImpl::~BatteryListenerImpl()
{ {
{ {
std::lock_guard<std::mutex> _l(mLock); std::lock_guard<std::mutex> _l(mLock);
if (mHealth != NULL) if (mHealth != NULL) {
mHealth->unregisterCallback(this); mHealth->unregisterCallback(this);
auto r = mHealth->unlinkToDeath(this); auto r = mHealth->unlinkToDeath(this);
if (!r.isOk() || r == false) { if (!r.isOk() || r == false) {
LOC_LOGe("Transaction error in unregister to HealthHAL death: %s", LOC_LOGe("Transaction error in unregister to HealthHAL death: %s",
r.description().c_str()); r.description().c_str());
} }
}
} }
mDone = true; mDone = true;
mThread->join(); if (NULL != mThread) {
mThread->join();
}
} }
void BatteryListenerImpl::serviceDied(uint64_t cookie __unused, void BatteryListenerImpl::serviceDied(uint64_t cookie __unused,
@ -210,7 +213,9 @@ void BatteryListenerImpl::serviceDied(uint64_t cookie __unused,
} }
mHealth = NULL; mHealth = NULL;
mCond.notify_one(); mCond.notify_one();
mThread->join(); if (NULL != mThread) {
mThread->join();
}
std::lock_guard<std::mutex> _l(mLock); std::lock_guard<std::mutex> _l(mLock);
init(); init();
} }