nuttx-apps/examples/configdata
Arnav Sharma 642720e9b4 examples/configdata: exercise unregister/register lifetime
Add a regression test for apache/nuttx#20166 to the configdata
example, which runs automatically in every sim:configdata build.
After the normal configdata test loops, close the long-lived
descriptor and run a full lifetime cycle on /dev/config:

- mtdconfig_unregister() must succeed,
- the unregistered device must no longer be openable (ENOENT),
- the same MTD device must be registerable again and usable,
- a final unregister must succeed, leaving the device unregistered.

Before the driver fix this crashes deterministically: the old
mtdconfig_unregister_by_path() freed the private device structure
before closing its temporary file, so the subsequent open() faults
in mm_malloc on the corrupted heap (SIGSEGV observed on sim right
after unregister returns).  With the fix the whole example,
934706/934706 checks included, completes cleanly.

The test uses only generic configdata APIs, so it also passes
unchanged under CONFIG_MTD_CONFIG_NVS, whose open/close callbacks
are no-ops.

Assisted-by: Claude:claude-opus
Signed-off-by: Arnav Sharma <2006arnavsharma@gmail.com>
2026-09-18 16:35:34 +08:00
..
CMakeLists.txt examples: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
configdata_main.c examples/configdata: exercise unregister/register lifetime 2026-09-18 16:35:34 +08:00
Kconfig Run codespell -w with the latest dictonary again 2020-02-23 07:10:14 -06:00
Make.defs examples: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
Makefile examples: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00