Skip to content

drivers: counter: Remove redundant alarm_cfg null check #92708

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

moonlight83340
Copy link
Contributor

Moved the null check for 'alarm_cfg' before accessing its fields to avoid undefined behavior in case of NULL.

Copy link
Collaborator

@JarmouniA JarmouniA left a comment

Choose a reason for hiding this comment

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

There is nothing to fix here, the NULL check should be removed all together, cfg struct is normally defined statically and its pointer is not going to magically turn NULL at runtime.

The alarm_cfg pointer is assumed to be non-NULL by contract. The null
check has been removed as it was either redundant or hiding a programming
error.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
@moonlight83340 moonlight83340 force-pushed the rz_gtm-set_alarm-null-check branch from 4c1815a to f74cc91 Compare July 5, 2025 03:40
@moonlight83340 moonlight83340 requested a review from JarmouniA July 5, 2025 03:41
@moonlight83340 moonlight83340 changed the title drivers: counter: Fix null dereference in set_alarm drivers: counter: Remove redundant alarm_cfg null check Jul 5, 2025
Copy link

sonarqubecloud bot commented Jul 5, 2025

@ttmut
Copy link
Collaborator

ttmut commented Jul 6, 2025

counter_alarm_cfg can potentially be NULL, as it's provided by the application. It's safer not to assume static initialization.

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

Successfully merging this pull request may close these issues.

5 participants