Skip to content

Commit

Permalink
[trel] fix crash (openthread#10894)
Browse files Browse the repository at this point in the history
Started from openthread#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.
  • Loading branch information
sunytt authored Nov 4, 2024
1 parent 854e92a commit b0984af
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/posix/platform/trel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,7 @@ void otPlatTrelEnable(otInstance *aInstance, uint16_t *aUdpPort)

VerifyOrExit(!IsSystemDryRun());

assert(sInitialized);

VerifyOrExit(!sEnabled);
VerifyOrExit(sInitialized && !sEnabled);

PrepareSocket(*aUdpPort);
trelDnssdStartBrowse();
Expand All @@ -493,8 +491,7 @@ void otPlatTrelDisable(otInstance *aInstance)

VerifyOrExit(!IsSystemDryRun());

assert(sInitialized);
VerifyOrExit(sEnabled);
VerifyOrExit(sInitialized && sEnabled);

close(sSocket);
sSocket = -1;
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit b0984af

Please sign in to comment.