-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Closed
Bug
Copy link
Labels
CoverityA Coverity detected issue or its fixA Coverity detected issue or its fixarea: SensorsSensorsSensorsbugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bugMedium impact/importance bug
Description
Static code scan issues found in file:
Category: Integer handling issues
Function: tsic_xx6_get_value
Component: Drivers
CID: 368811
Details:
zephyr/drivers/sensor/tsic_xx6/tsic_xx6.c
Line 164 in dcf4291
| tmp = data_bits * (config->higher_temperature_limit - config->lower_temperature_limit); |
158 static void tsic_xx6_get_value(const struct tsic_xx6_config *config, struct tsic_xx6_data *data,
159 uint16_t data_bits)
160 {
161 int64_t tmp;
162
163 /* Apply the datasheet formula scaled to micro celcius */
>>> CID 368811: Integer handling issues (SIGN_EXTENSION)
>>> Suspicious implicit sign extension: "data_bits" with type "uint16_t" (16 bits, unsigned) is promoted in "data_bits * (config->higher_temperature_limit - config->lower_temperature_limit)" to type "int" (32 bits, signed), then sign-extended to type "long long" (64 bits, signed). If "data_bits * (config->higher_temperature_limit - config->lower_temperature_limit)" is greater than 0x7FFFFFFF, the upper bits of the result will all be 1.
164 tmp = data_bits * (config->higher_temperature_limit - config->lower_temperature_limit);
165 tmp = tmp * 1000000 / (BIT(config->data_bits) - 1);
166 tmp += (int64_t)config->lower_temperature_limit * 1000000;
167
168 data->val.val1 = tmp / 1000000;
169 data->val.val2 = tmp % 1000000;
For more information about the violation, check the Coverity Reference. (CWE-194)
Please fix or provide comments in coverity using the link:
https://scan9.scan.coverity.com/#/project-view/29271/12996?selectedIssue=368811
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
Assignees
Labels
CoverityA Coverity detected issue or its fixA Coverity detected issue or its fixarea: SensorsSensorsSensorsbugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bugMedium impact/importance bug