pm: device_runtime: Fix possible underflow
The runtime API is referenced count and uses a uint32_t. Avoid underflow when dealing with put requests. Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
parent
93ae6e930a
commit
4960a9aa7a
1 changed files with 5 additions and 0 deletions
|
@ -113,6 +113,11 @@ static int pm_device_request(const struct device *dev,
|
|||
goto out_unlock;
|
||||
}
|
||||
} else {
|
||||
/* Check if it is already 0 to avoid an underflow */
|
||||
if (dev->pm->usage == 0) {
|
||||
goto out_unlock;
|
||||
}
|
||||
|
||||
dev->pm->usage--;
|
||||
if (dev->pm->usage > 0) {
|
||||
goto out_unlock;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue