Module: xenomai-3
Branch: stable-3.0.x
Commit: aeb7f49e6d4c4c8ffda61b2e2c317607cc621329
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=aeb7f49e6d4c4c8ffda61b2e2c317607cc621329

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sat May 14 15:20:34 2016 +0200

rtipc/iddp: fix cleanup on binding error

---

 kernel/drivers/ipc/iddp.c |   30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/kernel/drivers/ipc/iddp.c b/kernel/drivers/ipc/iddp.c
index 59508f6..028e40a 100644
--- a/kernel/drivers/ipc/iddp.c
+++ b/kernel/drivers/ipc/iddp.c
@@ -192,24 +192,24 @@ static void iddp_close(struct rtdm_fd *fd)
        void *poolmem;
        u32 poolsz;
 
-       if (sk->name.sipc_port > -1) {
-               cobalt_atomic_enter(s);
-               xnmap_remove(portmap, sk->name.sipc_port);
-               cobalt_atomic_leave(s);
-       }
-
        rtdm_sem_destroy(&sk->insem);
        rtdm_waitqueue_destroy(&sk->privwaitq);
 
-       if (sk->handle)
-               xnregistry_remove(sk->handle);
-
-       if (sk->bufpool != &cobalt_heap) {
-               poolmem = xnheap_get_membase(&sk->privpool);
-               poolsz = xnheap_get_size(&sk->privpool);
-               xnheap_destroy(&sk->privpool);
-               xnheap_vfree(poolmem);
-               return;
+       if (test_bit(_IDDP_BOUND, &sk->status)) {
+               if (sk->handle)
+                       xnregistry_remove(sk->handle);
+               if (sk->name.sipc_port > -1) {
+                       cobalt_atomic_enter(s);
+                       xnmap_remove(portmap, sk->name.sipc_port);
+                       cobalt_atomic_leave(s);
+               }
+               if (sk->bufpool != &cobalt_heap) {
+                       poolmem = xnheap_get_membase(&sk->privpool);
+                       poolsz = xnheap_get_size(&sk->privpool);
+                       xnheap_destroy(&sk->privpool);
+                       xnheap_vfree(poolmem);
+                       return;
+               }
        }
 
        /* Send unread datagrams back to the system heap. */


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

Reply via email to