]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/posix-process: Add assertions in ukthread2pid / ukthread2tid
authorMichalis Pappas <michalis@unikraft.io>
Tue, 2 Apr 2024 11:08:57 +0000 (13:08 +0200)
committerUnikraft Bot <monkey@unikraft.io>
Wed, 26 Mar 2025 08:05:34 +0000 (08:05 +0000)
Add assertions against passing a NULL pointer parameter in
ukthread2pid / ukthread2tid.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Ioan-Teodor Teugea <ioan_teodor.teugea@stud.acs.upb.ro>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Andrei Tatar <andrei@unikraft.io>
Approved-by: Andrei Tatar <andrei@unikraft.io>
GitHub-Closes: #1248

lib/posix-process/process.c

index d2cd45002cca7371c43a5d50d7a9b1fa7b96762f..84c3dae7f9ff7ec3be5bc5ded6e7296186ef6771 100644 (file)
@@ -510,6 +510,8 @@ pid_t ukthread2tid(struct uk_thread *thread)
 {
        struct posix_thread *pthread;
 
+       UK_ASSERT(thread);
+
        pthread = uk_thread_uktls_var(thread, pthread_self);
        if (!pthread)
                return -ENOTSUP;
@@ -521,6 +523,8 @@ pid_t ukthread2pid(struct uk_thread *thread)
 {
        struct posix_thread *pthread;
 
+       UK_ASSERT(thread);
+
        pthread = uk_thread_uktls_var(thread, pthread_self);
        if (!pthread)
                return -ENOTSUP;