Skip to content
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

[Coverity CID :206393] Unintentional integer overflow in drivers/sensor/ms5607/ms5607.c #21673

Closed
zephyrbot opened this issue Jan 3, 2020 · 0 comments · Fixed by #21965
Closed
Assignees
Labels
bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: low Low impact/importance bug

Comments

@zephyrbot
Copy link
Collaborator

Static code scan issues found in file:

https://github.com/zephyrproject-rtos/zephyr/tree/53392ad403db3a3c63e5802e620ead569306b978/drivers/sensor/ms5607/ms5607.c#L46

Category: Integer handling issues
Function: ms5607_compensate
Component: Drivers
CID: 206393

Details:

40    
41         /* Second order compensation as per datasheet
42          * (https://u2389337.ct.sendgrid.net/wf/click?upn=08onrYu34A-2BWcWUl-2F-2BfV0TEF4VnH9i4TTIUca3VjgWqR5l81E0p6T-2FViHGDkSsAj65ka8TVMpufDw-2BTcrguPPA-3D-3D_qb0Uj4AheYo18oR3ufs7U2EqDpE-2BCuzW5lXxy9dw9-2BA3R8-2ByM7YmWdwvIDfPUpFgx2wpkGg-2FxlOjavYrZghXJf6PWXyrC70buJ8HmWAgQWXAurgcxgm8aCWoixXlxrnC1YUHdMLIIwn7xm-2BS2i5zfvhCtszeMz-2FaE23P6qqCPyAnhlI7AxQa3sJCrVaOXd4xVaOq3gKrfE-2BYPjcw0C4cm1QHMgEKQ13L0nDixFikyTrfV5Z7KMUj1JClPTICyCrM section
43          * SECOND ORDER TEMPERATURE COMPENSATION
44          */
45    
>>>     CID 206393:  Integer handling issues  (OVERFLOW_BEFORE_WIDEN)
>>>     Potentially overflowing expression "(data->temperature - 2000) * (data->temperature - 2000)" with type "int" (32 bits, signed) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type "s64_t" (64 bits, signed).
46         temp_sq = (data->temperature - 2000) * (data->temperature - 2000);
47         if (data->temperature < 2000) {
48             Ti = (dT * dT) / (1ll << 31);
49             OFFi = (61ll * temp_sq) / (1ll << 4);
50             SENSi = 2ll * temp_sq;
51             if (data->temperature < -1500) {

Please fix or provide comments in coverity using the link:

https://scan9.coverity.com/reports.htm#v32951/p12996.

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 CODEOWNERS file.

@zephyrbot zephyrbot added bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: low Low impact/importance bug labels Jan 3, 2020
rckTom added a commit to rckTom/zephyr that referenced this issue Jan 15, 2020
Fix potential integer overflow by making operands to multiplication
wider.

Fixes zephyrproject-rtos#21673

Signed-off-by: Thomas Schmid <tom@lfence.de>
MaureenHelm pushed a commit that referenced this issue Jan 16, 2020
Fix potential integer overflow by making operands to multiplication
wider.

Fixes #21673

Signed-off-by: Thomas Schmid <tom@lfence.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants