Skip to content

Fix driver open modes and mount lifetime during hotplug work - #72

Merged
JohnAmadis merged 2 commits into
mainfrom
fix/map-device-open-modes
Oct 16, 2026
Merged

JohnAmadis merged 2 commits into
mainfrom
fix/map-device-open-modes

Conversation

@JaxCalder

@JaxCalder JaxCalder commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Valid read/write VFS opens use DMFSI_O_RDWR=3, while strict drivers expect DMDRVI_O_RDWR=4. Translate access bits at the filesystem/driver boundary, preserve existing modifiers and reject missing access bits. Add per-handle mock-driver coverage for all access modes.

Repeated mount/unmount also exposed a use-after-free in asynchronous node reporting: the hotplug worker checked that a mount was live, released the mutex, then used driver metadata and module pointers after unmount could free them. Retain the mount throughout unlocked worker operations; unmount unregisters it first and waits on a semaphore for active work before freeing drivers. Generation-tagged mount notifications reject stale queued pointers when an allocator reuses a mount address. Driver callbacks and waits run outside the global registry mutex.

Validation: full native ctest 10/10; test_order, test_dmdevmon and the new deterministic lifetime regression each pass 20 consecutive executions. The regression pauses a class probe, starts unmount concurrently and verifies no driver free or completed unmount until the probe is released; queued work for an unrelated mount can be cancelled meanwhile. Running it against the exact pre-fix source fails (premature driver free/unmount, exit 1). STM32F7 build passed. The board booted with commit 4172cf2: RTC 12/12, dmdrvi 6/6, RNG 6/6, cat /dev/rtc and DHCP confirmed after Verified OK flashing. Details: docs/open-mode-validation.md.

Test consumers clear inherited MAL implementation settings. Dependency versions remain inferred by the packager. RTC consumer: choco-technologies/dmrtc#1.

@JaxCalder JaxCalder changed the title Translate VFS access modes into driver open flags Fix driver open modes and mount lifetime during hotplug work Oct 16, 2026
@JohnAmadis
JohnAmadis merged commit 32939a7 into main Oct 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants