summaryrefslogtreecommitdiff
path: root/bus.c
diff options
context:
space:
mode:
authorDaniel Mack <zonque@gmail.com>2014-01-22 19:01:36 +0100
committerDaniel Mack <zonque@gmail.com>2014-01-22 20:06:13 +0100
commitd3a2e8523f37a439e33638b39eac6a38e8c74c89 (patch)
treeac7928a6bb0675f82ef345affa09e6cfbf6e4aa9 /bus.c
parent15be0b0366095ba4f762b6c7b25bb32be559f86e (diff)
downloadkdbus-bus-d3a2e8523f37a439e33638b39eac6a38e8c74c89.tar.gz
kdbus-bus-d3a2e8523f37a439e33638b39eac6a38e8c74c89.tar.bz2
kdbus-bus-d3a2e8523f37a439e33638b39eac6a38e8c74c89.zip
bus: move __user stuff to handle.c
bus
Diffstat (limited to 'bus.c')
-rw-r--r--bus.c84
1 files changed, 23 insertions, 61 deletions
diff --git a/bus.c b/bus.c
index 37f45d4eda4..7523244584c 100644
--- a/bus.c
+++ b/bus.c
@@ -267,7 +267,6 @@ exit:
/**
* kdbus_bus_make_user() - create a kdbus_cmd_make from user-supplied data
- * @buf: The user supplied data from the ioctl() call
* @make: Reference to the location where to store the result
* @name: Shortcut to the requested name
* @bloom_size: The bloom filter size as denoted in the make items
@@ -277,100 +276,63 @@ exit:
*
* Return: 0 on success, negative errno on failure.
*/
-int kdbus_bus_make_user(void __user *buf, struct kdbus_cmd_make **make,
+int kdbus_bus_make_user(struct kdbus_cmd_make *make,
char **name, size_t *bloom_size)
{
- u64 size;
- struct kdbus_cmd_make *m;
const char *n = NULL;
const struct kdbus_item *item;
u64 bsize = 0;
int ret;
- if (kdbus_size_get_user(&size, buf, struct kdbus_cmd_make))
- return -EFAULT;
-
- if (size < sizeof(struct kdbus_cmd_make) || size > KDBUS_MAKE_MAX_SIZE)
- return -EMSGSIZE;
-
- m = memdup_user(buf, size);
- if (IS_ERR(m))
- return PTR_ERR(m);
-
- KDBUS_ITEM_FOREACH(item, m, items) {
- if (!KDBUS_ITEM_VALID(item, m)) {
- ret = -EINVAL;
- goto exit;
- }
+ KDBUS_ITEM_FOREACH(item, make, items) {
+ if (!KDBUS_ITEM_VALID(item, make))
+ return -EINVAL;
switch (item->type) {
case KDBUS_ITEM_MAKE_NAME:
- if (n) {
- ret = -EEXIST;
- goto exit;
- }
+ if (n)
+ return -EEXIST;
- if (item->size < KDBUS_ITEM_HEADER_SIZE + 2) {
- ret = -EINVAL;
- goto exit;
- }
+ if (item->size < KDBUS_ITEM_HEADER_SIZE + 2)
+ return -EINVAL;
if (item->size > KDBUS_ITEM_HEADER_SIZE +
- KDBUS_SYSNAME_MAX_LEN + 1) {
- ret = -ENAMETOOLONG;
- goto exit;
- }
+ KDBUS_SYSNAME_MAX_LEN + 1)
+ return -ENAMETOOLONG;
if (!kdbus_validate_nul(item->str,
- item->size - KDBUS_ITEM_HEADER_SIZE)) {
- ret = -EINVAL;
- goto exit;
- }
+ item->size - KDBUS_ITEM_HEADER_SIZE))
+ return -EINVAL;
ret = kdbus_sysname_is_valid(item->str);
if (ret < 0)
- goto exit;
+ return ret;
n = item->str;
break;
case KDBUS_ITEM_BLOOM_SIZE:
- if (item->size < KDBUS_ITEM_HEADER_SIZE + sizeof(u64)) {
- ret = -EINVAL;
- goto exit;
- }
+ if (item->size < KDBUS_ITEM_HEADER_SIZE + sizeof(u64))
+ return -EINVAL;
bsize = item->data64[0];
break;
}
}
- if (!KDBUS_ITEM_END(item, m)) {
- ret = -EINVAL;
- goto exit;
- }
+ if (!KDBUS_ITEM_END(item, make))
+ return -EINVAL;
- if (!n) {
- ret = -EBADMSG;
- goto exit;
- }
+ if (!n)
+ return -EBADMSG;
- if (!KDBUS_IS_ALIGNED8(bsize)) {
- ret = -EINVAL;
- goto exit;
- }
+ if (!KDBUS_IS_ALIGNED8(bsize))
+ return -EINVAL;
- if (bsize < 8 || bsize > SZ_16K) {
- ret = -EINVAL;
- goto exit;
- }
+ if (bsize < 8 || bsize > SZ_16K)
+ return -EINVAL;
- *make = m;
*name = (char *)n;
*bloom_size = (size_t)bsize;
return 0;
-
-exit:
- kfree(m);
- return ret;
}