Commit b4e28030 authored by Geliang Tang's avatar Geliang Tang Committed by Mimi Zohar

ima: use memdup_user_nul

Use memdup_user_nul() helper instead of open-coding to simplify the
code.
Signed-off-by: default avatarGeliang Tang <geliangtang@gmail.com>
Signed-off-by: default avatarMimi Zohar <zohar@linux.vnet.ibm.com>
parent 5d659f28
...@@ -323,16 +323,11 @@ static ssize_t ima_write_policy(struct file *file, const char __user *buf, ...@@ -323,16 +323,11 @@ static ssize_t ima_write_policy(struct file *file, const char __user *buf,
if (*ppos != 0) if (*ppos != 0)
goto out; goto out;
result = -ENOMEM; data = memdup_user_nul(buf, datalen);
data = kmalloc(datalen + 1, GFP_KERNEL); if (IS_ERR(data)) {
if (!data) result = PTR_ERR(data);
goto out; goto out;
}
*(data + datalen) = '\0';
result = -EFAULT;
if (copy_from_user(data, buf, datalen))
goto out_free;
result = mutex_lock_interruptible(&ima_write_mutex); result = mutex_lock_interruptible(&ima_write_mutex);
if (result < 0) if (result < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment