Skip to content

[Coverity CID: 394233] Division or modulo by zero in drivers/sensor/tdk/icm42688/icm42688.h #75256

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

Closed
zephyrbot opened this issue Jul 1, 2024 · 2 comments · Fixed by #75970
Closed
Assignees
Labels
area: Sensors Sensors bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: medium Medium impact/importance bug

Comments

@zephyrbot
Copy link
Collaborator

Static code scan issues found in file:

https://github.com/zephyrproject-rtos/zephyr/tree/dcf42917c550714d2457947538b9e29d083e872e/drivers/sensor/tdk/icm42688/icm42688.h#L575

Category: Integer handling issues
Function: icm42688_gyro_rads
Component: Drivers
CID: 394233

Details:

* @brief Convert icm42688 accelerometer value to useful m/s^2 values

569              break;
570      }
571    
572      int64_t in10_rads = (int64_t)in * SENSOR_PI * 10LL;
573    
574      /* Whole rad/s */
>>>     CID 394233:  Integer handling issues  (DIVIDE_BY_ZERO)
>>>     In expression "in10_rads / (sensitivity * 180LL * 1000000LL)", division by expression "sensitivity * 180LL * 1000000LL" which may be zero has undefined behavior.
575      *out_rads = in10_rads / (sensitivity * 180LL * 1000000LL);
576    
577      /* microrad/s */
578      *out_urads =
579              (in10_rads - (*out_rads * sensitivity * 180LL * 1000000LL)) / (sensitivity * 180LL);
580     }

For more information about the violation, check the Coverity Reference. (CWE-369)

Please fix or provide comments in coverity using the link:

https://scan9.scan.coverity.com/#/project-view/29271/12996?selectedIssue=394233

Note: This issue was created automatically. Priority was set based on classification
of the file affected and the impact field in coverity. Assignees were set using the MAINTAINERS file.

@zephyrbot zephyrbot added area: Sensors Sensors bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: medium Medium impact/importance bug labels Jul 1, 2024
@zephyrbot zephyrbot reopened this Nov 25, 2024
@zephyrbot
Copy link
Collaborator Author

This coverity CID still appears as an outstanding issue. Please make sure any fixes correctly address the problem or triage the issue correctly in coverity on https://scan.coverity.com/.

@teburd
Copy link
Collaborator

teburd commented Jan 16, 2025

Coverity issue was closed, not sure why this is still open. Closing.

@teburd teburd closed this as completed Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Sensors Sensors bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: medium Medium impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants