-
Notifications
You must be signed in to change notification settings - Fork 442
zephyr update #434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zephyr update #434
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /* | ||
| * Copyright (c) 2025, sakumisu | ||
| * Copyright (c) 2025-2026 sakumisu | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
@@ -48,8 +48,12 @@ usb_osal_thread_t usb_osal_thread_create(const char *name, uint32_t stack_size, | |
| static void release_thread_handler(struct k_work *work) | ||
| { | ||
| struct release_thread_work *release_work = (struct release_thread_work *)work; | ||
| k_free(release_work->thread); | ||
| k_work_cancel(work); | ||
|
|
||
| /* The workqueue may preempt the thread that queued this work. Wait until | ||
| * k_thread_abort() has completed before freeing its TCB and stack. */ | ||
| if (k_thread_join(release_work->thread, K_FOREVER) == 0) { | ||
| k_free(release_work->thread); | ||
| } | ||
| k_free(release_work); | ||
| } | ||
|
|
||
|
|
@@ -63,6 +67,10 @@ void usb_osal_thread_delete(usb_osal_thread_t thread) | |
| thread = z_current_get(); | ||
| #endif | ||
| release_work = k_malloc(sizeof(struct release_thread_work)); | ||
| if (release_work == NULL) { | ||
| k_thread_abort(thread); | ||
| return; | ||
| } | ||
|
Comment on lines
+70
to
+73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift Release earlier allocations on every allocation failure path. The thread, message-queue, and timer paths all return after a later allocation fails without releasing the earlier allocation.
📍 Affects 1 file
🤖 Prompt for AI Agents |
||
| release_work->thread = thread; | ||
| k_work_init(&release_work->work, release_thread_handler); | ||
| k_work_submit(&release_work->work); | ||
|
|
@@ -309,4 +317,4 @@ void *usb_osal_malloc(size_t size) | |
| void usb_osal_free(void *ptr) | ||
| { | ||
| k_free(ptr); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /* | ||
| * Copyright (c) 2025, sakumisu | ||
| * Copyright (c) 2025-2026 sakumisu | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
@@ -131,12 +131,26 @@ static struct disk_info usbh_msc_disk = { | |
| .ops = &msc_disk_ops, | ||
| }; | ||
|
|
||
| __WEAK void usbh_msc_app_run(struct usbh_msc *msc_class) | ||
| { | ||
| (void)msc_class; | ||
| } | ||
|
|
||
| __WEAK void usbh_msc_app_stop(struct usbh_msc *msc_class) | ||
| { | ||
| (void)msc_class; | ||
| } | ||
|
|
||
| void usbh_msc_run(struct usbh_msc *msc_class) | ||
| { | ||
| disk_access_register(&usbh_msc_disk); | ||
|
|
||
| usbh_msc_app_run(msc_class); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C 6 \
'disk_access_register|disk_access_unregister|usbh_msc_app_(run|stop)' \
--glob '*.[ch]' .Repository: cherry-embedded/CherryUSB Length of output: 1781 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- repository metadata and Zephyr references ---'
git ls-files | rg '(^|/)(west\.yml|zephyr|CMakeLists\.txt|Kconfig|prj\.conf|module\.yml|VERSION|README)' | head -200
rg -n -C 3 \
'ZEPHYR_VERSION|zephyrproject|disk_access_register|disk_access_unregister|CONFIG_DISK_ACCESS' \
--glob '*.[ch]' --glob '*.cmake' --glob '*.yml' --glob '*.yaml' --glob '*.conf' --glob 'CMakeLists.txt' --glob 'Kconfig*' .
printf '%s\n' '--- target file ---'
sed -n '115,165p' platform/zephyr/usbh_msc_disk.c
printf '%s\n' '--- all lifecycle references ---'
rg -n -C 8 \
'usbh_msc_run|usbh_msc_stop|usbh_msc_app_(run|stop)|disk_access_register|disk_access_unregister' \
--glob '*.[ch]' .Repository: cherry-embedded/CherryUSB Length of output: 13978 🌐 Web query:
💡 Result: In the Zephyr RTOS, both the Citations:
🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- MSC connect/disconnect flow ---'
sed -n '280,360p' class/msc/usbh_msc.c
sed -n '1,120p' platform/zephyr/usbh_msc_disk.c
printf '%s\n' '--- Zephyr integration metadata ---'
cat zephyr/module.yml
cat VERSION
rg -n -C 4 'platform/zephyr|CONFIG_TEST_USBH_MSC|usbh_msc_disk' \
--glob '*.[ch]' --glob '*.cmake' --glob '*.yml' --glob '*.yaml' --glob '*.conf' --glob 'CMakeLists.txt' .Repository: cherry-embedded/CherryUSB Length of output: 10521 Gate the MSC application hooks on disk registration.
🤖 Prompt for AI AgentsSource: MCP tools |
||
| } | ||
|
|
||
| void usbh_msc_stop(struct usbh_msc *msc_class) | ||
| { | ||
| usbh_msc_app_stop(msc_class); | ||
|
|
||
| disk_access_unregister(&usbh_msc_disk); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Provide a non-fallible cleanup fallback when
k_work_submit()fails.Both cleanup paths depend on deferred work and then abort or return without handling submission failure. If submission fails, the handler does not run and the heap-backed thread allocation is leaked; the release-work path can also leak
release_work. Check the return status and perform cleanup through a mechanism that does not depend on the fallible submission before aborting or returning.📍 Affects 1 file
osal/usb_osal_zephyr.c#L51-L56(this comment)osal/usb_osal_zephyr.c#L70-L74osal/usb_osal_zephyr.c#L70-L74🤖 Prompt for AI Agents
Source: MCP tools