Skip to content

Commit a48450c

Browse files
committed
Add missing param checks in mem target functions
1 parent a5b5848 commit a48450c

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/memory_target.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ umf_result_t umfMemoryTargetClone(umf_memory_target_handle_t memoryTarget,
7979

8080
umf_result_t umfMemoryTargetGetCapacity(umf_memory_target_handle_t memoryTarget,
8181
size_t *capacity) {
82+
if (!memoryTarget || !capacity) {
83+
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
84+
}
85+
8286
assert(memoryTarget);
8387
assert(capacity);
8488
return memoryTarget->ops->get_capacity(memoryTarget->priv, capacity);
@@ -88,6 +92,10 @@ umf_result_t
8892
umfMemoryTargetGetBandwidth(umf_memory_target_handle_t srcMemoryTarget,
8993
umf_memory_target_handle_t dstMemoryTarget,
9094
size_t *bandwidth) {
95+
if (!srcMemoryTarget || !dstMemoryTarget || !bandwidth) {
96+
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
97+
}
98+
9199
assert(srcMemoryTarget);
92100
assert(dstMemoryTarget);
93101
assert(bandwidth);

src/memory_targets/memory_target_numa.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ static umf_result_t numa_clone(void *memTarget, void **outMemTarget) {
125125
}
126126

127127
static umf_result_t numa_get_capacity(void *memTarget, size_t *capacity) {
128+
if (!memTarget || !capacity) {
129+
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
130+
}
131+
128132
hwloc_topology_t topology = umfGetTopology();
129133
if (!topology) {
130134
return UMF_RESULT_ERROR_NOT_SUPPORTED;
@@ -147,6 +151,10 @@ static umf_result_t numa_get_capacity(void *memTarget, size_t *capacity) {
147151
static umf_result_t numa_get_bandwidth(void *srcMemoryTarget,
148152
void *dstMemoryTarget,
149153
size_t *bandwidth) {
154+
if (!srcMemoryTarget || !dstMemoryTarget || !bandwidth) {
155+
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
156+
}
157+
150158
hwloc_topology_t topology = umfGetTopology();
151159
if (!topology) {
152160
return UMF_RESULT_ERROR_NOT_SUPPORTED;

0 commit comments

Comments
 (0)