Skip to content

Commit acad953

Browse files
sudarsan-22MaureenHelm
authored andcommitted
drivers: sensor: voltage_divider: fix unchecked pm_device_runtime_get()
Fix Coverity CID 529858 (CWE-252): Previously, the return value of pm_device_runtime_get() was not checked during PM resume, which could lead to missed error conditions. This patch ensures proper error handling by checking and propagating the return status of the call. Fixes: #92608 Signed-off-by: sudarsan N <[email protected]>
1 parent 34bd7dc commit acad953

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/sensor/voltage_divider/voltage.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ static int pm_action(const struct device *dev, enum pm_device_action action)
127127
data->earliest_sample = K_TIMEOUT_ABS_TICKS(
128128
k_uptime_ticks() + k_us_to_ticks_ceil32(config->sample_delay_us));
129129
/* Power up ADC */
130-
pm_device_runtime_get(config->voltage.port.dev);
130+
ret = pm_device_runtime_get(config->voltage.port.dev);
131+
if (ret != 0) {
132+
LOG_ERR("failed to power up ADC (%d)", ret);
133+
return ret;
134+
}
131135
break;
132136
#ifdef CONFIG_PM_DEVICE
133137
case PM_DEVICE_ACTION_SUSPEND:
@@ -136,7 +140,11 @@ static int pm_action(const struct device *dev, enum pm_device_action action)
136140
LOG_ERR("failed to set GPIO for PM suspend");
137141
}
138142
/* Power down ADC */
139-
pm_device_runtime_put(config->voltage.port.dev);
143+
ret = pm_device_runtime_put(config->voltage.port.dev);
144+
if (ret != 0) {
145+
LOG_ERR("failed to Power down ADC (%d)", ret);
146+
return ret;
147+
}
140148
break;
141149
case PM_DEVICE_ACTION_TURN_OFF:
142150
break;

0 commit comments

Comments
 (0)