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

Author: Philippe Gerum <[email protected]>
Date:   Mon Nov  8 19:34:36 2010 +0100

nucleus/vfile: hold lock across ->store() ops

---

 ksrc/nucleus/vfile.c |   28 ++++++++++++++++++++++++++--
 1 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/ksrc/nucleus/vfile.c b/ksrc/nucleus/vfile.c
index 896b17b..c553480 100644
--- a/ksrc/nucleus/vfile.c
+++ b/ksrc/nucleus/vfile.c
@@ -326,12 +326,24 @@ ssize_t vfile_snapshot_write(struct file *file, const 
char __user *buf,
        struct proc_dir_entry *pde = PDE(wrap_f_inode(file));
        struct xnvfile_snapshot *vfile = pde->data;
        struct xnvfile_input input;
+       ssize_t ret;
+
+       if (vfile->entry.lockops) {
+               ret = vfile->entry.lockops->get(&vfile->entry);
+               if (ret)
+                       return ret;
+       }
 
        input.u_buf = buf;
        input.size = size;
        input.vfile = &vfile->entry;
 
-       return vfile->ops->store(&input);
+       ret = vfile->ops->store(&input);
+
+       if (vfile->entry.lockops)
+               vfile->entry.lockops->put(&vfile->entry);
+
+       return ret;
 }
 
 static struct file_operations vfile_snapshot_fops = {
@@ -572,12 +584,24 @@ ssize_t vfile_regular_write(struct file *file, const char 
__user *buf,
        struct proc_dir_entry *pde = PDE(wrap_f_inode(file));
        struct xnvfile_regular *vfile = pde->data;
        struct xnvfile_input input;
+       ssize_t ret;
+
+       if (vfile->entry.lockops) {
+               ret = vfile->entry.lockops->get(&vfile->entry);
+               if (ret)
+                       return ret;
+       }
 
        input.u_buf = buf;
        input.size = size;
        input.vfile = &vfile->entry;
 
-       return vfile->ops->store(&input);
+       ret = vfile->ops->store(&input);
+
+       if (vfile->entry.lockops)
+               vfile->entry.lockops->put(&vfile->entry);
+
+       return ret;
 }
 
 static struct file_operations vfile_regular_fops = {


_______________________________________________
Xenomai-git mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-git

Reply via email to