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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Tue May  3 12:16:29 2016 +0200

cobalt/rtdm: zero-init the private context area

---

 include/cobalt/kernel/rtdm/driver.h |    9 ++++++++-
 kernel/cobalt/rtdm/core.c           |    2 +-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index edd92ee..1354d9a 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -258,7 +258,14 @@ struct rtdm_driver {
         * @anchor rtdm_driver_flags
         */
        int device_flags;
-       /** Size of driver defined appendix to struct rtdm_dev_context */
+       /**
+        * Size of the private memory area the core should
+        * automatically allocate for each open file descriptor, which
+        * is usable for storing the context data associated to each
+        * connection. The allocated memory is zero-initialized. The
+        * start of this area can be retrieved by a call to
+        * rtdm_fd_to_private().
+        */
        size_t context_size;
        /** Protocol device identification: protocol family (PF_xxx) */
        int protocol_family;
diff --git a/kernel/cobalt/rtdm/core.c b/kernel/cobalt/rtdm/core.c
index 0f68e77..05f273f 100644
--- a/kernel/cobalt/rtdm/core.c
+++ b/kernel/cobalt/rtdm/core.c
@@ -86,7 +86,7 @@ static int create_instance(int ufd, struct rtdm_device *dev,
            atomic_read(&dev->refcount) > 1)
                return -EBUSY;
 
-       context = kmalloc(sizeof(struct rtdm_dev_context) +
+       context = kzalloc(sizeof(struct rtdm_dev_context) +
                          drv->context_size, GFP_KERNEL);
        if (unlikely(context == NULL))
                return -ENOMEM;


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

Reply via email to