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

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

rtipc/bufp: fix cleanup on binding error

---

 kernel/drivers/ipc/bufp.c |   20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/kernel/drivers/ipc/bufp.c b/kernel/drivers/ipc/bufp.c
index 6fc51d4..f129eaa 100644
--- a/kernel/drivers/ipc/bufp.c
+++ b/kernel/drivers/ipc/bufp.c
@@ -138,17 +138,19 @@ static void bufp_close(struct rtdm_fd *fd)
        rtdm_event_destroy(&sk->i_event);
        rtdm_event_destroy(&sk->o_event);
 
-       if (sk->name.sipc_port > -1) {
-               cobalt_atomic_enter(s);
-               xnmap_remove(portmap, sk->name.sipc_port);
-               cobalt_atomic_leave(s);
-       }
+       if (test_bit(_BUFP_BOUND, &sk->status)) {
+               if (sk->name.sipc_port > -1) {
+                       cobalt_atomic_enter(s);
+                       xnmap_remove(portmap, sk->name.sipc_port);
+                       cobalt_atomic_leave(s);
+               }
 
-       if (sk->handle)
-               xnregistry_remove(sk->handle);
+               if (sk->handle)
+                       xnregistry_remove(sk->handle);
 
-       if (sk->bufmem)
-               xnheap_vfree(sk->bufmem);
+               if (sk->bufmem)
+                       xnheap_vfree(sk->bufmem);
+       }
 
        kfree(sk);
 }


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

Reply via email to