Skip to content

Commit

Permalink
drivers: sensor: tmp108: fix coverity integer handling issue
Browse files Browse the repository at this point in the history
Fix coverity integer handling issue (CWE-188).
Modifying a variable through a pointer of an incompatible type (other
than unsigned char) can lead to unpredictable results.

Fix: #67965
Coverity-CID: 248434

Signed-off-by: Armando Visconti <[email protected]>
  • Loading branch information
avisconti authored and henrikbrixandersen committed Feb 5, 2024
1 parent 68ed2e0 commit 277d649
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/sensor/tmp108/tmp108.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ static int tmp108_attr_get(const struct device *dev,
struct sensor_value *val)
{
int result;
uint16_t tmp_val;

if (chan != SENSOR_CHAN_AMBIENT_TEMP && chan != SENSOR_CHAN_ALL) {
return -ENOTSUP;
Expand All @@ -174,7 +175,9 @@ static int tmp108_attr_get(const struct device *dev,
case SENSOR_ATTR_CONFIGURATION:
result = tmp108_reg_read(dev,
TI_TMP108_REG_CONF,
(uint16_t *) &(val->val1));
&tmp_val);
val->val1 = tmp_val;
val->val2 = 0;
break;
default:
return -ENOTSUP;
Expand Down

0 comments on commit 277d649

Please sign in to comment.