Skip to content

Commit 34473f6

Browse files
keith-packardcarlescufi
authored andcommitted
subsys/testsuite: Don't add empty z_malloc_partition to mem domain
The malloc partition may actually be empty, if so, don't try to add it to the domain as that will generate an error. Signed-off-by: Keith Packard <[email protected]>
1 parent e1e8179 commit 34473f6

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

subsys/testsuite/ztest/src/ztest.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -538,12 +538,15 @@ void main(void)
538538
}
539539
#ifdef Z_MALLOC_PARTITION_EXISTS
540540
/* Allow access to malloc() memory */
541-
ret = k_mem_domain_add_partition(&k_mem_domain_default,
542-
&z_malloc_partition);
543-
if (ret != 0) {
544-
PRINT("ERROR: failed to add z_malloc_partition to mem domain (%d)\n",
545-
ret);
546-
k_oops();
541+
if (z_malloc_partition.size != 0) {
542+
ret = k_mem_domain_add_partition(&k_mem_domain_default,
543+
&z_malloc_partition);
544+
if (ret != 0) {
545+
PRINT("ERROR: failed to add z_malloc_partition"
546+
" to mem domain (%d)\n",
547+
ret);
548+
k_oops();
549+
}
547550
}
548551
#endif
549552
#endif /* CONFIG_USERSPACE */

0 commit comments

Comments
 (0)