EVM: unlock on error path in evm_read_xattrs()
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 1 Jun 2018 08:00:05 +0000 (11:00 +0300)
committerMimi Zohar <zohar@linux.vnet.ibm.com>
Fri, 1 Jun 2018 10:03:08 +0000 (06:03 -0400)
We need to unlock before returning on this error path.

Fixes: fa516b66a1bf ("EVM: Allow runtime modification of the set of verified xattrs")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
security/integrity/evm/evm_secfs.c

index 3cefef3919e5806d3c3c2bd3eab7d6a2600cb628..637eb999e3406df16d084f50e779ed73f34b2ca4 100644 (file)
@@ -147,8 +147,10 @@ static ssize_t evm_read_xattrs(struct file *filp, char __user *buf,
                size += strlen(xattr->name) + 1;
 
        temp = kmalloc(size + 1, GFP_KERNEL);
-       if (!temp)
+       if (!temp) {
+               mutex_unlock(&xattr_list_mutex);
                return -ENOMEM;
+       }
 
        list_for_each_entry(xattr, &evm_config_xattrnames, list) {
                sprintf(temp + offset, "%s\n", xattr->name);