Skip to content
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

Flash API: flash_erase has incorrect userspace handler #81777

Open
de-nordic opened this issue Nov 22, 2024 · 0 comments · May be fixed by #81778
Open

Flash API: flash_erase has incorrect userspace handler #81777

de-nordic opened this issue Nov 22, 2024 · 0 comments · May be fixed by #81778
Assignees
Labels
bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Milestone

Comments

@de-nordic
Copy link
Collaborator

Describe the bug

Drivers have option to not implement erase, in which case pointer to erase callback may be left NULL:

static inline int z_impl_flash_erase(const struct device *dev, off_t offset,
size_t size)
{
int rc = -ENOSYS;

But handler for the erase has been left as it is always expected:

K_OOPS(K_SYSCALL_DRIVER_FLASH(dev, erase));

Expected behavior
Proper check should be done using K_SYSCALL_OBJ, to only verify the object, ignoring whether erase callback is assigned or not.

K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_FLASH))

Impact
Currently only on out-of-tree drivers that do not implement erase.

Environment (please complete the following information):

  • OS: Ubuntu 20
  • Toolchain Zephyr sdk 0.17.0
  • Commit SHA c14b022

Additional context
Verification Return Value Policies
K_SYSCALL_OBJ
K_SYSCALL_DRIVER_OP

@de-nordic de-nordic added the bug The issue is a bug, or the PR is fixing a bug label Nov 22, 2024
de-nordic added a commit to de-nordic/zephyr that referenced this issue Nov 22, 2024
As the erase callback is optional, handler should not check
if it is not NULL.

Fixes zephyrproject-rtos#81777

Signed-off-by: Dominik Ermel <[email protected]>
@de-nordic de-nordic self-assigned this Nov 22, 2024
@de-nordic de-nordic added this to the v4.1.0 milestone Nov 22, 2024
@de-nordic de-nordic added the priority: low Low impact/importance bug label Nov 22, 2024
de-nordic added a commit to de-nordic/zephyr that referenced this issue Nov 22, 2024
As the erase callback is optional, handler should not check
if it is not NULL.

Fixes zephyrproject-rtos#81777

Signed-off-by: Dominik Ermel <[email protected]>
de-nordic added a commit to de-nordic/zephyr that referenced this issue Nov 27, 2024
As the erase callback is optional, handler should not check
if it is not NULL.

Fixes zephyrproject-rtos#81777

Signed-off-by: Dominik Ermel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant