mirror of
https://github.com/espressif/openthread.git
synced 2026-09-10 03:00:09 +00:00
[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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user