summaryrefslogtreecommitdiff
path: root/core/include
diff options
context:
space:
mode:
authorGene Cumm <gene.cumm@gmail.com>2013-08-03 15:59:26 -0400
committerGene Cumm <gene.cumm@gmail.com>2013-08-03 15:59:26 -0400
commitdc3059be195f0b1c878273f648dcaf1b45c5a860 (patch)
tree5af91be81c9fdb305ce5b768f033aa1c3477c080 /core/include
parent64cf622143afc759062a44a255742a7413c6c5b4 (diff)
downloadsyslinux-dc3059be195f0b1c878273f648dcaf1b45c5a860.tar.gz
core: mbox/semaphore NULL checks
Also set mbox invalid and mbox pointer NULL when free()d Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
Diffstat (limited to 'core/include')
-rw-r--r--core/include/mbox.h5
-rw-r--r--core/include/thread.h5
2 files changed, 6 insertions, 4 deletions
diff --git a/core/include/mbox.h b/core/include/mbox.h
index 3c35ce4e..6fec267c 100644
--- a/core/include/mbox.h
+++ b/core/include/mbox.h
@@ -45,7 +45,8 @@ mstime_t mbox_fetch(struct mailbox *mbox, void **msg, mstime_t timeout);
*/
static inline void mbox_set_invalid(struct mailbox *mbox)
{
- sem_set_invalid(&mbox->prod_sem);
+ if (!!mbox)
+ sem_set_invalid(&mbox->prod_sem);
}
/*
@@ -53,7 +54,7 @@ static inline void mbox_set_invalid(struct mailbox *mbox)
*/
static inline bool mbox_is_valid(struct mailbox *mbox)
{
- return sem_is_valid(&mbox->prod_sem);
+ return ((!!mbox) && sem_is_valid(&mbox->prod_sem));
}
#endif /* _MBOX_H */
diff --git a/core/include/thread.h b/core/include/thread.h
index 6bfdfaa7..8ec4a267 100644
--- a/core/include/thread.h
+++ b/core/include/thread.h
@@ -93,7 +93,8 @@ void sem_init(struct semaphore *, int);
*/
static inline void sem_set_invalid(struct semaphore *sem)
{
- sem->list.next = NULL;
+ if (!!sem)
+ sem->list.next = NULL;
}
/*
@@ -101,7 +102,7 @@ static inline void sem_set_invalid(struct semaphore *sem)
*/
static inline bool sem_is_valid(struct semaphore *sem)
{
- return !!sem->list.next;
+ return ((!!sem) && (!!sem->list.next));
}
struct thread *start_thread(const char *name, size_t stack_size, int prio,