key: Fix resource leak
authorAlan Cox <alan@linux.intel.com>
Fri, 28 Sep 2012 11:20:02 +0000 (12:20 +0100)
committerDavid Howells <dhowells@redhat.com>
Fri, 28 Sep 2012 11:20:02 +0000 (12:20 +0100)
On an error iov may still have been reallocated and need freeing

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: David Howells <dhowells@redhat.com>
security/keys/keyctl.c

index 3364fbf46807bb384e61a761f2f6f2fab9ebb888..a0d373f76815c2eafb172666e05e6d9b81220584 100644 (file)
@@ -1112,12 +1112,12 @@ long keyctl_instantiate_key_iov(key_serial_t id,
        ret = rw_copy_check_uvector(WRITE, _payload_iov, ioc,
                                    ARRAY_SIZE(iovstack), iovstack, &iov);
        if (ret < 0)
-               return ret;
+               goto err;
        if (ret == 0)
                goto no_payload_free;
 
        ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
-
+err:
        if (iov != iovstack)
                kfree(iov);
        return ret;