aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGene Cumm <gene.cumm@gmail.com>2013-08-03 16:01:28 -0400
committerGene Cumm <gene.cumm@gmail.com>2013-08-03 16:01:28 -0400
commitceb14335790f70378dddfbf0202d2bcda0c54a03 (patch)
tree3bf1c6a16c5b5493444839db54846e21ac33074f
parentdc3059be195f0b1c878273f648dcaf1b45c5a860 (diff)
downloadsyslinux-ceb14335790f70378dddfbf0202d2bcda0c54a03.tar.gz
syslinux-ceb14335790f70378dddfbf0202d2bcda0c54a03.tar.xz
syslinux-ceb14335790f70378dddfbf0202d2bcda0c54a03.zip
core: make mbox_post()/__sem_down_slow() check if valid
If the mailbox/semaphore is invalid, disallow additions. Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
-rw-r--r--core/thread/mbox.c2
-rw-r--r--core/thread/semaphore.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/core/thread/mbox.c b/core/thread/mbox.c
index 6ad576ba..d1c640a9 100644
--- a/core/thread/mbox.c
+++ b/core/thread/mbox.c
@@ -24,7 +24,7 @@ void mbox_init(struct mailbox *mbox, size_t size)
int mbox_post(struct mailbox *mbox, void *msg, mstime_t timeout)
{
- if (!mbox)
+ if (!mbox_is_valid(mbox))
return ENOMEM;
if (sem_down(&mbox->prod_sem, timeout) == (mstime_t)-1)
return ENOMEM;
diff --git a/core/thread/semaphore.c b/core/thread/semaphore.c
index abd4f418..c99af9c5 100644
--- a/core/thread/semaphore.c
+++ b/core/thread/semaphore.c
@@ -16,7 +16,7 @@ mstime_t __sem_down_slow(struct semaphore *sem, mstime_t timeout)
irq = irq_save();
- if (!sem) {
+ if (!sem_is_valid(sem)) {
rv = -1;
} else if (sem->count >= 0) {
/* Something already freed the semaphore on us */