[syslinux:elflink] core: make mbox_post()/__sem_down_slow() check if valid

syslinux-bot for Gene Cumm gene.cumm at gmail.com
Mon Sep 30 04:18:09 PDT 2013


Commit-ID:  ceb14335790f70378dddfbf0202d2bcda0c54a03
Gitweb:     http://www.syslinux.org/commit/ceb14335790f70378dddfbf0202d2bcda0c54a03
Author:     Gene Cumm <gene.cumm at gmail.com>
AuthorDate: Sat, 3 Aug 2013 16:01:28 -0400
Committer:  Gene Cumm <gene.cumm at gmail.com>
CommitDate: Sat, 3 Aug 2013 16:01:28 -0400

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 at gmail.com>

---
 core/thread/mbox.c      | 2 +-
 core/thread/semaphore.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/core/thread/mbox.c b/core/thread/mbox.c
index 6ad576b..d1c640a 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 abd4f41..c99af9c 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 */


More information about the Syslinux-commits mailing list