Skip to content

Commit 2845794

Browse files
[Telink] Fix NotifyAdvertisingStopped with Null node
Since in file src/platform/Zephyr/BLEAdvertisingArbiter.cpp function InsertRequest obtains previous node using iteration via slist - condition (prev == nullptr) is only true if slist is empty. In that case NotifyAdvertisingStopped is always called with Null and no Null checker inside the function. As result crash.
1 parent 5bdfb75 commit 2845794

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/platform/Zephyr/BLEAdvertisingArbiter.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ CHIP_ERROR InsertRequest(Request & request)
9090

9191
if (prev == nullptr)
9292
{
93-
NotifyAdvertisingStopped(sys_slist_peek_head(&sRequests));
9493
sys_slist_prepend(&sRequests, &request);
9594
}
9695
else
@@ -110,6 +109,13 @@ CHIP_ERROR InsertRequest(Request & request)
110109
void CancelRequest(Request & request)
111110
{
112111
const bool isTopPriority = (sys_slist_peek_head(&sRequests) == &request);
112+
113+
// If cancelled request was top-priority, stop the advertising.
114+
if (isTopPriority)
115+
{
116+
NotifyAdvertisingStopped(sys_slist_peek_head(&sRequests));
117+
}
118+
113119
VerifyOrReturn(sys_slist_find_and_remove(&sRequests, &request));
114120

115121
// If cancelled request was top-priority, restart the advertising.

0 commit comments

Comments
 (0)