Module: xenomai-forge
Branch: master
Commit: f75c2afb48dde2b1d47c5ccdde09c0bc83c6ec48
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=f75c2afb48dde2b1d47c5ccdde09c0bc83c6ec48

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Sun Apr 14 16:19:16 2013 +0200

testsuite/switchtest: handle device open error

Currently, switchtest uses the failure of the first ioctl on its device to
know that it was in fact not the correct device. But the error can also be
due to the ioctl failing to allocate memory with kmalloc, which indeed happens
on system with many CPUs. Fix this issue by:
- using vmalloc instead of kmalloc to have a higher upper bound on allocation
size;
- only considering ENOSYS and ENOTTY as indication that the device is not the
right one.

---

 kernel/drivers/testing/switchtest.c |    7 ++++---
 testsuite/switchtest/switchtest.c   |    5 +++++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/kernel/drivers/testing/switchtest.c 
b/kernel/drivers/testing/switchtest.c
index e078917..1b49bbb 100644
--- a/kernel/drivers/testing/switchtest.c
+++ b/kernel/drivers/testing/switchtest.c
@@ -1,3 +1,4 @@
+#include <linux/vmalloc.h>
 #include <nucleus/pod.h>
 #include <nucleus/synch.h>
 #include <nucleus/thread.h>
@@ -323,7 +324,7 @@ static int rtswitch_set_tasks_count(rtswitch_context_t 
*ctx, unsigned count)
        if (ctx->tasks_count == count)
                return 0;
 
-       tasks = kmalloc(count * sizeof(*tasks), GFP_KERNEL);
+       tasks = vmalloc(count * sizeof(*tasks));
 
        if (!tasks)
                return -ENOMEM;
@@ -331,7 +332,7 @@ static int rtswitch_set_tasks_count(rtswitch_context_t 
*ctx, unsigned count)
        down(&ctx->lock);
 
        if (ctx->tasks)
-               kfree(ctx->tasks);
+               vfree(ctx->tasks);
 
        ctx->tasks = tasks;
        ctx->tasks_count = count;
@@ -543,7 +544,7 @@ static int rtswitch_close(struct rtdm_dev_context *context,
                        }
                        rtdm_event_destroy(&task->rt_synch);
                }
-               kfree(ctx->tasks);
+               vfree(ctx->tasks);
        }
        rtdm_timer_destroy(&ctx->wake_up_delay);
        rtdm_nrtsig_destroy(&ctx->wake_utask);
diff --git a/testsuite/switchtest/switchtest.c 
b/testsuite/switchtest/switchtest.c
index 5ef5c8e..de0ba6c 100644
--- a/testsuite/switchtest/switchtest.c
+++ b/testsuite/switchtest/switchtest.c
@@ -912,6 +912,11 @@ static int open_rttest(char *buf, size_t size, unsigned 
count)
                if (status == 0)
                        break;
 
+               if (errno != ENOSYS && errno != ENOTTY) {
+                       fprintf(stderr, "switchtest: open: %m\n");
+                       return -1;
+               }
+
          next_dev:
                if (fd != -1)
                        close(fd);


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

Reply via email to