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

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

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.

---

 ksrc/drivers/testing/switchtest.c     |    6 +++---
 src/testsuite/switchtest/switchtest.c |    5 +++++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/ksrc/drivers/testing/switchtest.c 
b/ksrc/drivers/testing/switchtest.c
index addf66a..33c1934 100644
--- a/ksrc/drivers/testing/switchtest.c
+++ b/ksrc/drivers/testing/switchtest.c
@@ -322,7 +322,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;
@@ -330,7 +330,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 +543,7 @@ static int rtswitch_close(struct rtdm_dev_context *context,
                                xnpod_delete_thread(&task->ktask);
                        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/src/testsuite/switchtest/switchtest.c 
b/src/testsuite/switchtest/switchtest.c
index 3b3c24a..051c1b0 100644
--- a/src/testsuite/switchtest/switchtest.c
+++ b/src/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