Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions osal/usb_osal_rtthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ usb_osal_thread_t usb_osal_thread_create(const char *name, uint32_t stack_size,
void usb_osal_thread_delete(usb_osal_thread_t thread)
{
if (thread == NULL) {
rt_thread_t self = rt_thread_self();
rt_thread_control(self, RT_THREAD_CTRL_CLOSE, RT_NULL);
Comment on lines +29 to +30
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Validate return value of rt_thread_self().

The return value of rt_thread_self() should be validated to ensure we don't pass a NULL thread to rt_thread_control().

     if (thread == NULL) {
         rt_thread_t self = rt_thread_self();
+        if (self == RT_NULL) {
+            USB_LOG_ERR("Failed to get current thread\r\n");
+            return;
+        }
         rt_thread_control(self, RT_THREAD_CTRL_CLOSE, RT_NULL);

Committable suggestion skipped: line range outside the PR's diff.

return;
}

Expand Down
Loading