]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
examples: Fix checking id parameter in thread_start
authorFrancois Berder <fberder@outlook.fr>
Sat, 22 Nov 2025 20:45:02 +0000 (21:45 +0100)
committerTom Rini <trini@konsulko.com>
Fri, 5 Dec 2025 22:23:54 +0000 (16:23 -0600)
lthreads is of size MAX_THREADS, hence id must be lower than
MAX_THREADS to avoid any potential buffer overflow in
thread_start function.

Signed-off-by: Francois Berder <fberder@outlook.fr>
examples/standalone/sched.c

index 57ae67e1a5bc39eeb748c226157f95a20ac6470b..64518c6890f8d015c1d4f8002a43cebeccec4902 100644 (file)
@@ -261,9 +261,8 @@ static void thread_launcher (void)
 static int thread_start (int id)
 {
        PDEBUG ("thread_start: id=%d", id);
-       if (id <= MASTER_THREAD || id > MAX_THREADS) {
+       if (id <= MASTER_THREAD || id >= MAX_THREADS)
                return RC_FAILURE;
-       }
 
        if (lthreads[id].state != STATE_STOPPED)
                return RC_FAILURE;