Skip to content

drivers/mtd: keep MTDIOC_ERASESECTORS inside its partition - #20405

Open
royzah wants to merge 1 commit into
apache:masterfrom
royzah:mtd-erase-sectors
Open

royzah wants to merge 1 commit into
apache:masterfrom
royzah:mtd-erase-sectors

Conversation

@royzah

@royzah royzah commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Note: Please adhere to Contributing Guidelines.

Summary

MTDIOC_ERASESECTORS on a partition went straight to the parent with no bound, so an erase from the last block on hit the next partition. part_erase() already checks it.

Call part_erase(). Plus the nxstyle fixes in the file.

Impact

MTD partitions. An erase past the end of a partition fails instead of erasing the next one.

Testing

Host: Ubuntu 24.04, x86_64. Builds and QEMU runs in ghcr.io/apache/nuttx/apache-nuttx-ci-linux (QEMU 6.2, Arm GNU GCC 13.2, xPack RISC-V GCC 14.3). Hardware: i.MX93 (Cortex-A55), PX4 kernel build.

i.MX93, 64 MB FlexSPI NOR in partitions, MTDIOC_ERASESECTORS from the block past the end of a 7680-block partition:

result
before erases the next partition's first block (read from the code, not run: it holds an image)
after -ENXIO
erase block 7680 of a 7680-block partition: -1, errno 6
i.MX93, PX4 kernel build, this series applied: tests isolation
INFO  [tests] RUNNING TEST: test_erase_bounded
INFO  [tests] erase block 7680 of a 7680-block partition: -1, errno 6
INFO  [tests] TEST PASSED: test_erase_bounded
INFO  [tests]   Tests passed :      15
INFO  [tests]   Tests failed :      0

tools/checkpatch.sh clean.

@github-actions github-actions Bot added Area: Drivers Drivers issues Size: XS The size of the change in this PR is very small labels Sep 30, 2026
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

The ioctl passed the erase to the parent unchecked, so an erase from the
last block on reached the next partition. part_erase() already bounds it.

Signed-off-by: Royyan Zahir <royzah@gmail.com>
@royzah
royzah force-pushed the mtd-erase-sectors branch from 21e39db to cc05517 Compare October 1, 2026 01:29
@royzah

royzah commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Two approvals and CI is green, could a committer merge this one when there's a moment? Thanks!

@xiaoxiang781216

Copy link
Copy Markdown
Contributor

Two approvals and CI is green, could a committer merge this one when there's a moment? Thanks!

but need two committer/pmc approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Drivers Drivers issues Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants