Skip to content

Commit c8fff0c

Browse files
ananglkartben
authored andcommitted
drivers: clock_control_nrf2: Add missing cancelation of request
This is a follow-up to commit fe0e2db. If `nrf_clock_control_request_sync()` ends up with a timeout, before returning it must cancel the request that was not fulfilled on time. Otherwise, the request may actually finish successfully a bit later, but the caller will not be aware that the clock needs to be released (since the call resulted in an error). And actually even more serious problem is that because the `req` structure is placed on stack, after the function returns, the contents of this structure will be probably overwritten with some other data, so if the request finishes at that point, an attempt to execute the callback function pointed by this structure will most likely cause a crash. Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
1 parent a736e84 commit c8fff0c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/clock_control/clock_control_nrf2_common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ int nrf_clock_control_request_sync(const struct device *dev,
235235

236236
err = k_sem_take(&req.sem, timeout);
237237
if (err < 0) {
238+
nrf_clock_control_cancel_or_release(dev, spec, &req.cli);
238239
return err;
239240
}
240241

0 commit comments

Comments
 (0)