handle: unref handle->ep and free handle->meta on error path
authorDjalal Harouni <tixxdz@opendz.org>
Sun, 23 Mar 2014 23:20:36 +0000 (00:20 +0100)
committerKay Sievers <kay@vrfy.org>
Mon, 24 Mar 2014 02:48:42 +0000 (03:48 +0100)
Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
handle.c

index 921faca5149d19e0d5e74605b3e3ff7424cc7561..3af611968f88e496289ce01181ed2ff42267bc42 100644 (file)
--- a/handle.c
+++ b/handle.c
@@ -130,7 +130,7 @@ static int kdbus_handle_open(struct inode *inode, struct file *file)
        /* cache the metadata/credentials of the creator of the connection */
        ret = kdbus_meta_new(&handle->meta);
        if (ret < 0)
-               goto exit_unlock;
+               goto exit_ep_unref;
 
        ret = kdbus_meta_append(handle->meta, NULL, 0,
                                KDBUS_ATTACH_CREDS |
@@ -142,11 +142,15 @@ static int kdbus_handle_open(struct inode *inode, struct file *file)
                                KDBUS_ATTACH_SECLABEL |
                                KDBUS_ATTACH_AUDIT);
        if (ret < 0)
-               goto exit_unlock;
+               goto exit_meta_free;
 
        mutex_unlock(&handle->domain->lock);
        return 0;
 
+exit_meta_free:
+       kdbus_meta_free(handle->meta);
+exit_ep_unref:
+       kdbus_ep_unref(handle->ep);
 exit_unlock:
        mutex_unlock(&handle->domain->lock);
        kdbus_domain_unref(handle->domain);