Skip to content

Commit

Permalink
ima_write_policy(): don't open-code memdup_user_nul()
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Jun 30, 2017
1 parent 0b884d2 commit 02412e9
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions security/integrity/ima/ima_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,16 +323,11 @@ static ssize_t ima_write_policy(struct file *file, const char __user *buf,
if (*ppos != 0)
goto out;

result = -ENOMEM;
data = kmalloc(datalen + 1, GFP_KERNEL);
if (!data)
data = memdup_user_nul(buf, datalen);
if (IS_ERR(data)) {
result = PTR_ERR(data);
goto out;

*(data + datalen) = '\0';

result = -EFAULT;
if (copy_from_user(data, buf, datalen))
goto out_free;
}

result = mutex_lock_interruptible(&ima_write_mutex);
if (result < 0)
Expand Down

0 comments on commit 02412e9

Please sign in to comment.