Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kernel/mempool: Handle transient failure condition
The sys_mem_pool implementation has a subtle error case where it detected a simultaneous allocation after having released the lock, in which case exactly one of the racing allocators will return with -EAGAIN (the other one suceeds of course). I documented this condition at the lower level, but forgot to actually handle it at the k_mem_pool level where we want to retry once before going to sleep, as it doesn't generally represent an empty heap. It got caught by code auditing in: zephyrproject-rtos#6757 (Full disclosure: I tested this by whiteboxing the first failure. I wasn't able to put together a rig to reliably exercise the actual race.) This patch also fixes a noop thinko in the return logic in the same function, which contained: (ret == -EAGAIN) || (ret && ret != -ENOMEM) The first term is needless and implied by the second. Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
- Loading branch information