drivers: sensor: tmp108: fix coverity integer handling issue
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 <armando.visconti@st.com>
This commit is contained in:
parent
68ed2e019f
commit
277d649bda
1 changed files with 4 additions and 1 deletions
|
@ -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;
|
||||
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue