]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cyclic: stop strdup'ing name in cyclic_register()
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>
Tue, 21 May 2024 08:46:50 +0000 (10:46 +0200)
committerStefan Roese <sr@denx.de>
Sun, 16 Jun 2024 10:13:38 +0000 (12:13 +0200)
We are not checking the return value of strdup(), nor
freeing the string in cyclic_unregister().

However, all current users either pass a string literal or the
dev->name of the client device. So in all cases the name string will
live at least as long as the cyclic_info is registered, so just make
that a requirement.

Reviewed-by: Stefan Roese <sr@denx.de>
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
common/cyclic.c
include/cyclic.h

index a49bfc88f5c0e96257b59d3b75033007a2b537ed..c62e7fa7d19e93e9138b62b977c2606555c5ac79 100644 (file)
@@ -40,7 +40,7 @@ struct cyclic_info *cyclic_register(cyclic_func_t func, uint64_t delay_us,
        /* Store values in struct */
        cyclic->func = func;
        cyclic->ctx = ctx;
-       cyclic->name = strdup(name);
+       cyclic->name = name;
        cyclic->delay_us = delay_us;
        cyclic->start_time_us = timer_get_us();
        hlist_add_head(&cyclic->list, cyclic_get_list());
index 44ad3cb6b8033bd105316ef00a93ef2233336546..38946216fb86ffcdaf1310a9ffb9bca0d95c1199 100644 (file)
@@ -31,7 +31,7 @@
 struct cyclic_info {
        void (*func)(void *ctx);
        void *ctx;
-       char *name;
+       const char *name;
        uint64_t delay_us;
        uint64_t start_time_us;
        uint64_t cpu_time_us;