Skip to content

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

@zephyrbot

Description

@zephyrbot

Static code scan issues found in file:

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

Category: Integer handling issues
Function: icm42688_accel_ms
Component: Drivers
CID: 394232

Details:

520      }
521    
522      /* Convert to micrometers/s^2 */
523      int64_t in_ms = in * SENSOR_G;
524    
525      /* meters/s^2 whole values */
>>>     CID 394232:  Integer handling issues  (DIVIDE_BY_ZERO)
>>>     In expression "in_ms / (sensitivity * 1000000LL)", division by expression "sensitivity * 1000000LL" which may be zero has undefined behavior.
526      *out_ms = in_ms / (sensitivity * 1000000LL);
527    
528      /* micrometers/s^2 */
529      *out_ums = (in_ms - (*out_ms * sensitivity * 1000000LL)) / sensitivity;
530     }
531    

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=394232

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.

Metadata

Metadata

Labels

CoverityA Coverity detected issue or its fixarea: SensorsSensorsbugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions