drivers: i3c: Use kernel heap for allocations
Use the kernel heap instead of the libc heap, improving security and consistency. Signed-off-by: Ibrahim Abdalkader <i.abdalkader@gmail.com>
This commit is contained in:
committed by
Fabio Baltieri
parent
f66ce9c251
commit
5e61c06c85
@@ -58,6 +58,14 @@ config I3C_TARGET_BUFFER_MODE
|
||||
help
|
||||
This is an option to enable buffer mode.
|
||||
|
||||
config HEAP_MEM_POOL_ADD_SIZE_I3C
|
||||
int "Heap memory pool size for I3C"
|
||||
default 48
|
||||
depends on I3C_CONTROLLER && I3C_TARGET
|
||||
help
|
||||
The size of the memory pool used by I3C. Used only for
|
||||
DEFTGTS (Define List of Targets) CCC (Common Command Code).
|
||||
|
||||
menuconfig I3C_USE_IBI
|
||||
bool "Use In-Band Interrupt (IBI)"
|
||||
default y
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/toolchain.h>
|
||||
#include <zephyr/sys/__assert.h>
|
||||
#include <zephyr/sys/slist.h>
|
||||
@@ -1327,7 +1328,7 @@ int i3c_bus_deftgts(const struct device *dev)
|
||||
}
|
||||
|
||||
/* Allocate memory for the struct with enough space for the targets */
|
||||
deftgts = malloc(data_len);
|
||||
deftgts = k_malloc(data_len);
|
||||
if (!deftgts) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
@@ -1371,7 +1372,7 @@ int i3c_bus_deftgts(const struct device *dev)
|
||||
|
||||
ret = i3c_ccc_do_deftgts_all(dev, deftgts);
|
||||
|
||||
free(deftgts);
|
||||
k_free(deftgts);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user