names: fix total length of kvecs
authorDaniel Mack <daniel@zonque.org>
Fri, 9 Jan 2015 18:03:34 +0000 (19:03 +0100)
committerDaniel Mack <daniel@zonque.org>
Fri, 9 Jan 2015 18:06:29 +0000 (19:06 +0100)
Don't let kdbus_pool_slice_alloc() copy the kvecs along with allocating
the slice. The problem is that we only want to copy the header of the
block in this case, which doesn't work when the implicit behavior is
used.

Hence, open-code the functionality. Fixes an Ooops on 3.19-rc3.

Signed-off-by: Daniel Mack <daniel@zonque.org>
names.c

diff --git a/names.c b/names.c
index 95d435f336d8b9f2cc59d38932a638ba2f4b2b7b..9af3a6923013a62bec093cb44b1685931ce36318 100644 (file)
--- a/names.c
+++ b/names.c
@@ -862,13 +862,17 @@ int kdbus_cmd_name_list(struct kdbus_name_registry *reg,
        kvec.iov_base = &list;
        kvec.iov_len = sizeof(list);
 
-       slice = kdbus_pool_slice_alloc(conn->pool, list.size, &kvec, NULL, 1);
+       slice = kdbus_pool_slice_alloc(conn->pool, list.size, NULL, NULL, 0);
        if (IS_ERR(slice)) {
                ret = PTR_ERR(slice);
                slice = NULL;
                goto exit_unlock;
        }
 
+       ret = kdbus_pool_slice_copy_kvec(slice, 0, &kvec, 1, kvec.iov_len);
+       if (ret < 0)
+               goto exit_unlock;
+
        /* copy the records */
        pos = sizeof(struct kdbus_name_list);
        ret = kdbus_name_list_all(conn, cmd->flags, slice, &pos, true);