Module: xenomai-3
Branch: wip/gpio
Commit: 2af3ab42d7a38f93e56ae714a446ce7c8d66bfc8
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2af3ab42d7a38f93e56ae714a446ce7c8d66bfc8

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Fri May 27 08:32:41 2016 +0200

cobalt/rtdm: Fix driver reference counting

The rtdm smokey test triggered a BUG due to rtdm_dev_unregister not
taking the reference counter of a driver into account. Fix this by
moving the check into unregister_driver directly.

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>

---

 kernel/cobalt/rtdm/device.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c
index aa62169..8c54890 100644
--- a/kernel/cobalt/rtdm/device.c
+++ b/kernel/cobalt/rtdm/device.c
@@ -324,6 +324,9 @@ static void unregister_driver(struct rtdm_driver *drv)
 {
        XENO_BUG_ON(COBALT, drv->profile_info.magic != RTDM_CLASS_MAGIC);
 
+       if (!atomic_dec_and_test(&drv->refcount))
+               return;
+
        cobalt_remove_state_chain(&drv->nb_statechange);
 
        drv->profile_info.magic = ~RTDM_CLASS_MAGIC;
@@ -477,8 +480,7 @@ fail:
        if (kdev)
                device_destroy(kdev_class, rdev);
 
-       if (atomic_dec_and_test(&drv->refcount))
-               unregister_driver(drv);
+       unregister_driver(drv);
 
        mutex_unlock(&register_lock);
 


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

Reply via email to