Module: xenomai-3
Branch: stable-3.0.x
Commit: c90fc4bfa88ac8540f8592d34fb0f490d2ef1677
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c90fc4bfa88ac8540f8592d34fb0f490d2ef1677

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sun Jan 24 16:03:28 2016 +0100

drivers/ipc/xddp: fixup allocation rounding for tiny private pool sizes

With tiny pool sizes specified by userland (< PAGE_SIZE), we may end
up with the streaming buffer consuming all the available pool memory
at once, due to the full page allocation scheme used by the underlying
allocator (size > PAGE_SIZE * 2).

To determine the per-socket pool size, round the user size and the
streaming buffer size separately, before summing the two results, so
that tiny sizes are eventually rounded to PAGE_SIZE.

---

 kernel/drivers/ipc/xddp.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/drivers/ipc/xddp.c b/kernel/drivers/ipc/xddp.c
index 2923b69..9bd3644 100644
--- a/kernel/drivers/ipc/xddp.c
+++ b/kernel/drivers/ipc/xddp.c
@@ -689,7 +689,8 @@ static int __xddp_bind_socket(struct rtipc_private *priv,
 
        poolsz = sk->poolsz;
        if (poolsz > 0) {
-               poolsz = xnheap_rounded_size(poolsz + sk->reqbufsz);
+               poolsz = xnheap_rounded_size(poolsz);
+               poolsz += xnheap_rounded_size(sk->reqbufsz);
                poolmem = alloc_pages_exact(poolsz, GFP_KERNEL);
                if (poolmem == NULL) {
                        ret = -ENOMEM;


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to