convert a bunch of open-coded instances of memdup_user_nul()
A _lot_ of ->write() instances were open-coding it; some are converted to memdup_user_nul(), a lot more remain... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
@@ -896,15 +896,9 @@ int rxrpc_request_key(struct rxrpc_sock *rx, char __user *optval, int optlen)
|
||||
if (optlen <= 0 || optlen > PAGE_SIZE - 1)
|
||||
return -EINVAL;
|
||||
|
||||
description = kmalloc(optlen + 1, GFP_KERNEL);
|
||||
if (!description)
|
||||
return -ENOMEM;
|
||||
|
||||
if (copy_from_user(description, optval, optlen)) {
|
||||
kfree(description);
|
||||
return -EFAULT;
|
||||
}
|
||||
description[optlen] = 0;
|
||||
description = memdup_user_nul(optval, optlen);
|
||||
if (IS_ERR(description))
|
||||
return PTR_ERR(description);
|
||||
|
||||
key = request_key(&key_type_rxrpc, description, NULL);
|
||||
if (IS_ERR(key)) {
|
||||
@@ -933,15 +927,9 @@ int rxrpc_server_keyring(struct rxrpc_sock *rx, char __user *optval,
|
||||
if (optlen <= 0 || optlen > PAGE_SIZE - 1)
|
||||
return -EINVAL;
|
||||
|
||||
description = kmalloc(optlen + 1, GFP_KERNEL);
|
||||
if (!description)
|
||||
return -ENOMEM;
|
||||
|
||||
if (copy_from_user(description, optval, optlen)) {
|
||||
kfree(description);
|
||||
return -EFAULT;
|
||||
}
|
||||
description[optlen] = 0;
|
||||
description = memdup_user_nul(optval, optlen);
|
||||
if (IS_ERR(description))
|
||||
return PTR_ERR(description);
|
||||
|
||||
key = request_key(&key_type_keyring, description, NULL);
|
||||
if (IS_ERR(key)) {
|
||||
|
Reference in New Issue
Block a user