[trel] fix crash (#10894)

Started from #10872, platform trel stays un-initialized if no TREL URL is
passed in. `otPlatTrelEnable` asserted for `sInitialized`, and caused
crashes when `otPlatTrelEnable()` is called.

This commit changes the assertions to VerifyOrExit() to allow
otPlatTrelEnable calls when TREL is not initialized.
This commit is contained in:
Yang Sun
2024-11-04 16:05:55 +01:00
committed by GitHub
parent 854e92a40a
commit b0984aff7a
+4 -5
View File
@@ -474,9 +474,7 @@ void otPlatTrelEnable(otInstance *aInstance, uint16_t *aUdpPort)
VerifyOrExit(!IsSystemDryRun());
assert(sInitialized);
VerifyOrExit(!sEnabled);
VerifyOrExit(sInitialized && !sEnabled);
PrepareSocket(*aUdpPort);
trelDnssdStartBrowse();
@@ -493,8 +491,7 @@ void otPlatTrelDisable(otInstance *aInstance)
VerifyOrExit(!IsSystemDryRun());
assert(sInitialized);
VerifyOrExit(sEnabled);
VerifyOrExit(sInitialized && sEnabled);
close(sSocket);
sSocket = -1;
@@ -541,6 +538,8 @@ void otPlatTrelRegisterService(otInstance *aInstance, uint16_t aPort, const uint
OT_UNUSED_VARIABLE(aInstance);
VerifyOrExit(!IsSystemDryRun());
VerifyOrExit(sEnabled);
trelDnssdRegisterService(aPort, aTxtData, aTxtLength);
exit: