handle: fix potential mem leak when kdbus_conn_kmsg_send() fails
authorDaniel Mack <zonque@gmail.com>
Fri, 17 Jan 2014 23:02:37 +0000 (00:02 +0100)
committerDaniel Mack <zonque@gmail.com>
Fri, 17 Jan 2014 23:02:37 +0000 (00:02 +0100)
handle.c

index c5ef0542404ef87da3b44eb2a65e1a4543022e0e..599fdc6fde7df00a552d24fce300452435035fba 100644 (file)
--- a/handle.c
+++ b/handle.c
@@ -609,8 +609,10 @@ static long kdbus_handle_ioctl_ep_connected(struct file *file, unsigned int cmd,
                        break;
 
                ret = kdbus_conn_kmsg_send(conn->ep, conn, kmsg);
-               if (ret < 0)
+               if (ret < 0) {
+                       kdbus_kmsg_free(kmsg);
                        break;
+               }
 
                /* store the offset of the reply back to userspace */
                if (kmsg->msg.flags & KDBUS_MSG_FLAGS_SYNC_REPLY) {