Module: xenomai-jki
Branch: for-upstream
Commit: 50db06419bf9b7838ed4aadf7c2202ea1dd68b25
URL:    
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=50db06419bf9b7838ed4aadf7c2202ea1dd68b25

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Fri Feb 26 18:42:35 2010 +0100

RTDM+POSIX: Avoid leaking binding objects on errors

We need to release the allocated xnselect_binding if we fail to hook it
into the select block.

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>

---

 ksrc/skins/posix/mq.c    |    1 +
 ksrc/skins/rtdm/drvlib.c |    6 ++++++
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/ksrc/skins/posix/mq.c b/ksrc/skins/posix/mq.c
index 11f47c0..a896031 100644
--- a/ksrc/skins/posix/mq.c
+++ b/ksrc/skins/posix/mq.c
@@ -1283,6 +1283,7 @@ int pse51_mq_select_bind(mqd_t fd, struct xnselector 
*selector,
        return 0;
 
       unlock_and_error:
+       xnfree(binding):
        xnlock_put_irqrestore(&nklock, s);
        return err;
 }
diff --git a/ksrc/skins/rtdm/drvlib.c b/ksrc/skins/rtdm/drvlib.c
index 5181108..637f99e 100644
--- a/ksrc/skins/rtdm/drvlib.c
+++ b/ksrc/skins/rtdm/drvlib.c
@@ -1089,6 +1089,9 @@ int rtdm_event_select_bind(rtdm_event_t *event, 
rtdm_selector_t *selector,
                                                       RTDM_EVENT_PENDING));
        xnlock_put_irqrestore(&nklock, s);
 
+       if (err)
+               xnfree(binding);
+
        return err;
 }
 EXPORT_SYMBOL(rtdm_event_select_bind);
@@ -1370,6 +1373,9 @@ int rtdm_sem_select_bind(rtdm_sem_t *sem, rtdm_selector_t 
*selector,
                                    type, fd_index, (sem->value > 0));
        xnlock_put_irqrestore(&nklock, s);
 
+       if (err)
+               xnfree(binding);
+
        return err;
 }
 EXPORT_SYMBOL(rtdm_sem_select_bind);


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to