Skip to content

led: fix up the ENOSYS condition to pass coverity #90734

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

Merged
merged 1 commit into from
May 30, 2025

Conversation

fabiobaltieri
Copy link
Member

The current ENOSYS check code can proceed for a driver that hypothetically implements the on() but not the off() function of vice versa, which would result in a null pointer dereference.

This would be a weird use case but Coverity catches the situation, no harm in changing the ENOSYS check to fail if the on/off is half implemented, so let's change it to do that.

Fixes #90484

@fabiobaltieri fabiobaltieri marked this pull request as ready for review May 28, 2025 10:44
@github-actions github-actions bot added the area: LED Label to identify LED subsystem label May 28, 2025
simonguinot
simonguinot previously approved these changes May 28, 2025
Copy link
Collaborator

@simonguinot simonguinot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this issue.

The current ENOSYS check code can proceed for a driver that
hypothetically implements the on() but not the off() function of
vice versa, which would result in a null pointer dereference.

This would be a weird use case but Coverity catches the situation, no
harm in changing the ENOSYS check to fail if the on/off is half
implemented, so let's change it to do that.

Signed-off-by: Fabio Baltieri <[email protected]>
Copy link

@kartben kartben merged commit 0336721 into zephyrproject-rtos:main May 30, 2025
26 checks passed
@fabiobaltieri fabiobaltieri deleted the led-coverity branch June 11, 2025 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: LED Label to identify LED subsystem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Coverity CID: 524764] Dereference after null check in include/zephyr/drivers/led.h
9 participants