Skip to content

Commit d443128

Browse files
committed
Add missing param checks in mem target functions
1 parent 92dbb25 commit d443128

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/memory_target.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,21 @@ 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-
assert(memoryTarget);
83-
assert(capacity);
82+
if (!memoryTarget || !capacity) {
83+
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
84+
}
85+
8486
return memoryTarget->ops->get_capacity(memoryTarget->priv, capacity);
8587
}
8688

8789
umf_result_t
8890
umfMemoryTargetGetBandwidth(umf_memory_target_handle_t srcMemoryTarget,
8991
umf_memory_target_handle_t dstMemoryTarget,
9092
size_t *bandwidth) {
91-
assert(srcMemoryTarget);
92-
assert(dstMemoryTarget);
93-
assert(bandwidth);
93+
if (!srcMemoryTarget || !dstMemoryTarget || !bandwidth) {
94+
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
95+
}
96+
9497
return srcMemoryTarget->ops->get_bandwidth(
9598
srcMemoryTarget->priv, dstMemoryTarget->priv, bandwidth);
9699
}

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)