summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kern/thread.c4
-rw-r--r--kern/thread.h3
2 files changed, 6 insertions, 1 deletions
diff --git a/kern/thread.c b/kern/thread.c
index 85e557d3..e79ef311 100644
--- a/kern/thread.c
+++ b/kern/thread.c
@@ -2367,7 +2367,9 @@ thread_create(struct thread **threadp, const struct thread_attr *attr,
* The new thread address must be written before the thread is started
* in case it's passed to it.
*/
- *threadp = thread;
+ if (threadp) {
+ *threadp = thread;
+ }
thread_wakeup(thread);
diff --git a/kern/thread.h b/kern/thread.h
index 4bead755..6e696fc7 100644
--- a/kern/thread.h
+++ b/kern/thread.h
@@ -182,6 +182,9 @@ void thread_ap_setup(void);
* Creation attributes must be passed, but some of them may be NULL, in which
* case the value is inherited from the caller. The name attribute must not be
* NULL.
+ *
+ * If successful, and if the caller passed a non-NULL thread pointer, it is
+ * filled with the address of the newly created thread.
*/
int thread_create(struct thread **threadp, const struct thread_attr *attr,
void (*fn)(void *), void *arg);