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

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Fri Apr  2 01:21:55 2010 +0200

RTIPC: Fix memory leak on failing socket creation

CC: Philippe Gerum <r...@xenomai.org>
Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>

---

 ksrc/drivers/ipc/rtipc.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/ksrc/drivers/ipc/rtipc.c b/ksrc/drivers/ipc/rtipc.c
index d529912..563cc4e 100644
--- a/ksrc/drivers/ipc/rtipc.c
+++ b/ksrc/drivers/ipc/rtipc.c
@@ -143,6 +143,7 @@ static int rtipc_socket(struct rtdm_dev_context *context,
 {
        struct rtipc_protocol *proto;
        struct rtipc_private *p;
+       int ret;
 
        if (protocol < 0 || protocol >= IPCPROTO_MAX)
                return -EPROTONOSUPPORT;
@@ -161,7 +162,11 @@ static int rtipc_socket(struct rtdm_dev_context *context,
        if (p->state == NULL)
                return -ENOMEM;
 
-       return proto->proto_ops.socket(p, user_info);
+       ret = proto->proto_ops.socket(p, user_info);
+       if (ret)
+               xnfree(p->state);
+
+       return ret;
 }
 
 static int rtipc_close(struct rtdm_dev_context *context,


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

Reply via email to