kernel: Add CONFIG_MEM_SLAB_POINTER_VALIDATE
Makes the validation of both allocated memory slab pointer and the memory slab pointer to free configurable. Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
This commit is contained in:
parent
f0516ead27
commit
869acdbbab
2 changed files with 11 additions and 0 deletions
|
@ -677,6 +677,13 @@ config POLL
|
||||||
concurrently, which can be either directly triggered or triggered by
|
concurrently, which can be either directly triggered or triggered by
|
||||||
the availability of some kernel objects (semaphores and FIFOs).
|
the availability of some kernel objects (semaphores and FIFOs).
|
||||||
|
|
||||||
|
config MEM_SLAB_POINTER_VALIDATE
|
||||||
|
bool "Validate the memory slab pointer when allocating or freeing"
|
||||||
|
default ASSERT
|
||||||
|
help
|
||||||
|
This enables additional runtime checks to validate the memory slab
|
||||||
|
pointer during when allocating or freeing a memory slab.
|
||||||
|
|
||||||
config MEM_SLAB_TRACE_MAX_UTILIZATION
|
config MEM_SLAB_TRACE_MAX_UTILIZATION
|
||||||
bool "Getting maximum slab utilization"
|
bool "Getting maximum slab utilization"
|
||||||
help
|
help
|
||||||
|
|
|
@ -206,6 +206,10 @@ out:
|
||||||
|
|
||||||
static bool slab_ptr_is_good(struct k_mem_slab *slab, const void *ptr)
|
static bool slab_ptr_is_good(struct k_mem_slab *slab, const void *ptr)
|
||||||
{
|
{
|
||||||
|
if (!IS_ENABLED(CONFIG_MEM_SLAB_POINTER_VALIDATE)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
const char *p = ptr;
|
const char *p = ptr;
|
||||||
ptrdiff_t offset = p - slab->buffer;
|
ptrdiff_t offset = p - slab->buffer;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue