Skip to content

Flash API: flash_erase has incorrect userspace handler #81777

@de-nordic

Description

@de-nordic

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

Metadata

Metadata

Assignees

Labels

bugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bug

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions