[Xenomai-git] Gilles Chanteperdrix : rtdm/devices: avoid incomplete device cleanup
Module: xenomai-3 Branch: master Commit: 96e85548a56c8c7fbd6d64c079701483a8e5da27 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=96e85548a56c8c7fbd6d64c079701483a8e5da27 Author: Gilles Chanteperdrix Date: Tue Sep 29 01:41:26 2015 +0200 rtdm/devices: avoid incomplete device cleanup when unregister_driver() is called from rtdm_dev_unregister(), __rtdm_put_device() has already decreased the driver reference count, so the result of atomic_dec_and_test() is always false and unregister_driver() does not finish the cleanup. Fix this by moving the atomic_dec_and_test() test to the only other call site of unregister_driver(): the rtdm_dev_regiter() error path. --- kernel/cobalt/rtdm/device.c |7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c index 1c602c2..9af2221 100644 --- a/kernel/cobalt/rtdm/device.c +++ b/kernel/cobalt/rtdm/device.c @@ -303,6 +303,7 @@ static int register_driver(struct rtdm_driver *drv) drv->named.major = MAJOR(rdev); atomic_set(&drv->refcount, 1); + done: drv->nb_statechange.notifier_call = state_change_notifier; drv->nb_statechange.priority = 0; @@ -321,9 +322,6 @@ 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_notifier_chain(&drv->nb_statechange); if (drv->device_flags & RTDM_NAMED_DEVICE) { @@ -452,7 +450,8 @@ fail: if (kdev) device_destroy(rtdm_class, rdev); - unregister_driver(drv); + if (atomic_dec_and_test(&drv->refcount)) + unregister_driver(drv); mutex_unlock(®ister_lock); ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Gilles Chanteperdrix : rtdm/devices: avoid incomplete device cleanup
Module: xenomai-3 Branch: arm64 Commit: 96e85548a56c8c7fbd6d64c079701483a8e5da27 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=96e85548a56c8c7fbd6d64c079701483a8e5da27 Author: Gilles Chanteperdrix Date: Tue Sep 29 01:41:26 2015 +0200 rtdm/devices: avoid incomplete device cleanup when unregister_driver() is called from rtdm_dev_unregister(), __rtdm_put_device() has already decreased the driver reference count, so the result of atomic_dec_and_test() is always false and unregister_driver() does not finish the cleanup. Fix this by moving the atomic_dec_and_test() test to the only other call site of unregister_driver(): the rtdm_dev_regiter() error path. --- kernel/cobalt/rtdm/device.c |7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c index 1c602c2..9af2221 100644 --- a/kernel/cobalt/rtdm/device.c +++ b/kernel/cobalt/rtdm/device.c @@ -303,6 +303,7 @@ static int register_driver(struct rtdm_driver *drv) drv->named.major = MAJOR(rdev); atomic_set(&drv->refcount, 1); + done: drv->nb_statechange.notifier_call = state_change_notifier; drv->nb_statechange.priority = 0; @@ -321,9 +322,6 @@ 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_notifier_chain(&drv->nb_statechange); if (drv->device_flags & RTDM_NAMED_DEVICE) { @@ -452,7 +450,8 @@ fail: if (kdev) device_destroy(rtdm_class, rdev); - unregister_driver(drv); + if (atomic_dec_and_test(&drv->refcount)) + unregister_driver(drv); mutex_unlock(®ister_lock); ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Gilles Chanteperdrix : rtdm/devices: avoid incomplete device cleanup
Module: xenomai-3 Branch: next Commit: 96e85548a56c8c7fbd6d64c079701483a8e5da27 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=96e85548a56c8c7fbd6d64c079701483a8e5da27 Author: Gilles Chanteperdrix Date: Tue Sep 29 01:41:26 2015 +0200 rtdm/devices: avoid incomplete device cleanup when unregister_driver() is called from rtdm_dev_unregister(), __rtdm_put_device() has already decreased the driver reference count, so the result of atomic_dec_and_test() is always false and unregister_driver() does not finish the cleanup. Fix this by moving the atomic_dec_and_test() test to the only other call site of unregister_driver(): the rtdm_dev_regiter() error path. --- kernel/cobalt/rtdm/device.c |7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c index 1c602c2..9af2221 100644 --- a/kernel/cobalt/rtdm/device.c +++ b/kernel/cobalt/rtdm/device.c @@ -303,6 +303,7 @@ static int register_driver(struct rtdm_driver *drv) drv->named.major = MAJOR(rdev); atomic_set(&drv->refcount, 1); + done: drv->nb_statechange.notifier_call = state_change_notifier; drv->nb_statechange.priority = 0; @@ -321,9 +322,6 @@ 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_notifier_chain(&drv->nb_statechange); if (drv->device_flags & RTDM_NAMED_DEVICE) { @@ -452,7 +450,8 @@ fail: if (kdev) device_destroy(rtdm_class, rdev); - unregister_driver(drv); + if (atomic_dec_and_test(&drv->refcount)) + unregister_driver(drv); mutex_unlock(®ister_lock); ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Gilles Chanteperdrix : rtdm/devices: avoid incomplete device cleanup
Module: xenomai-gch Branch: for-forge Commit: a7c4fa5331d48a6405b72dca00443e2d23fff5e3 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=a7c4fa5331d48a6405b72dca00443e2d23fff5e3 Author: Gilles Chanteperdrix Date: Tue Sep 29 01:41:26 2015 +0200 rtdm/devices: avoid incomplete device cleanup when unregister_driver() is called from rtdm_dev_unregister(), __rtdm_put_device() has already decreased the driver reference count, so the result of atomic_dec_and_test() is always false and unregister_driver() does not finish the cleanup. Fix this by moving the atomic_dec_and_test() test to the only other call site of unregister_driver(): the rtdm_dev_regiter() error path. --- kernel/cobalt/rtdm/device.c |7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c index 1c602c2..9af2221 100644 --- a/kernel/cobalt/rtdm/device.c +++ b/kernel/cobalt/rtdm/device.c @@ -303,6 +303,7 @@ static int register_driver(struct rtdm_driver *drv) drv->named.major = MAJOR(rdev); atomic_set(&drv->refcount, 1); + done: drv->nb_statechange.notifier_call = state_change_notifier; drv->nb_statechange.priority = 0; @@ -321,9 +322,6 @@ 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_notifier_chain(&drv->nb_statechange); if (drv->device_flags & RTDM_NAMED_DEVICE) { @@ -452,7 +450,8 @@ fail: if (kdev) device_destroy(rtdm_class, rdev); - unregister_driver(drv); + if (atomic_dec_and_test(&drv->refcount)) + unregister_driver(drv); mutex_unlock(®ister_lock); ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Gilles Chanteperdrix : rtdm/devices: avoid incomplete device cleanup
Module: xenomai-gch Branch: for-forge Commit: 6380bb9ea6d407664e33b75e88d0d4e52fb2e804 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=6380bb9ea6d407664e33b75e88d0d4e52fb2e804 Author: Gilles Chanteperdrix Date: Tue Sep 29 01:41:26 2015 +0200 rtdm/devices: avoid incomplete device cleanup when unregister_driver() is called from rtdm_dev_unregister(), __rtdm_put_device() has already decreased the driver reference count, so the result of atomic_dec_and_test() is always false and unregister_driver() does not finish the cleanup. Fix this by moving the atomic_dec_and_test() test to the only other call site of unregister_driver(): the rtdm_dev_regiter() error path. --- kernel/cobalt/rtdm/device.c |7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c index 1c602c2..9af2221 100644 --- a/kernel/cobalt/rtdm/device.c +++ b/kernel/cobalt/rtdm/device.c @@ -303,6 +303,7 @@ static int register_driver(struct rtdm_driver *drv) drv->named.major = MAJOR(rdev); atomic_set(&drv->refcount, 1); + done: drv->nb_statechange.notifier_call = state_change_notifier; drv->nb_statechange.priority = 0; @@ -321,9 +322,6 @@ 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_notifier_chain(&drv->nb_statechange); if (drv->device_flags & RTDM_NAMED_DEVICE) { @@ -452,7 +450,8 @@ fail: if (kdev) device_destroy(rtdm_class, rdev); - unregister_driver(drv); + if (atomic_dec_and_test(&drv->refcount)) + unregister_driver(drv); mutex_unlock(®ister_lock); ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Gilles Chanteperdrix : rtdm/devices: avoid incomplete device cleanup
Module: xenomai-3 Branch: next Commit: c79073b77e4995356726b53948478c69808c3d91 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c79073b77e4995356726b53948478c69808c3d91 Author: Gilles Chanteperdrix Date: Tue Sep 29 01:41:26 2015 +0200 rtdm/devices: avoid incomplete device cleanup when unregister_driver() is called from rtdm_dev_unregister(), __rtdm_put_device() has already decreased the driver reference count, so the result of atomic_dec_and_test() is always false and unregister_driver() does not finish the cleanup. Fix this by moving the atomic_dec_and_test() test to the only other call site of unregister_driver(): the rtdm_dev_regiter() error path. --- kernel/cobalt/rtdm/device.c |7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c index 1c602c2..9af2221 100644 --- a/kernel/cobalt/rtdm/device.c +++ b/kernel/cobalt/rtdm/device.c @@ -303,6 +303,7 @@ static int register_driver(struct rtdm_driver *drv) drv->named.major = MAJOR(rdev); atomic_set(&drv->refcount, 1); + done: drv->nb_statechange.notifier_call = state_change_notifier; drv->nb_statechange.priority = 0; @@ -321,9 +322,6 @@ 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_notifier_chain(&drv->nb_statechange); if (drv->device_flags & RTDM_NAMED_DEVICE) { @@ -452,7 +450,8 @@ fail: if (kdev) device_destroy(rtdm_class, rdev); - unregister_driver(drv); + if (atomic_dec_and_test(&drv->refcount)) + unregister_driver(drv); mutex_unlock(®ister_lock); ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Gilles Chanteperdrix : rtdm/devices: avoid incomplete device cleanup
Module: xenomai-gch Branch: for-forge Commit: c79073b77e4995356726b53948478c69808c3d91 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=c79073b77e4995356726b53948478c69808c3d91 Author: Gilles Chanteperdrix Date: Tue Sep 29 01:41:26 2015 +0200 rtdm/devices: avoid incomplete device cleanup when unregister_driver() is called from rtdm_dev_unregister(), __rtdm_put_device() has already decreased the driver reference count, so the result of atomic_dec_and_test() is always false and unregister_driver() does not finish the cleanup. Fix this by moving the atomic_dec_and_test() test to the only other call site of unregister_driver(): the rtdm_dev_regiter() error path. --- kernel/cobalt/rtdm/device.c |7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c index 1c602c2..9af2221 100644 --- a/kernel/cobalt/rtdm/device.c +++ b/kernel/cobalt/rtdm/device.c @@ -303,6 +303,7 @@ static int register_driver(struct rtdm_driver *drv) drv->named.major = MAJOR(rdev); atomic_set(&drv->refcount, 1); + done: drv->nb_statechange.notifier_call = state_change_notifier; drv->nb_statechange.priority = 0; @@ -321,9 +322,6 @@ 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_notifier_chain(&drv->nb_statechange); if (drv->device_flags & RTDM_NAMED_DEVICE) { @@ -452,7 +450,8 @@ fail: if (kdev) device_destroy(rtdm_class, rdev); - unregister_driver(drv); + if (atomic_dec_and_test(&drv->refcount)) + unregister_driver(drv); mutex_unlock(®ister_lock); ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Gilles Chanteperdrix : rtdm/devices: avoid incomplete device cleanup
Module: xenomai-gch Branch: for-forge Commit: 1a5c5c41e3cf656616085518f33500c9fd895465 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=1a5c5c41e3cf656616085518f33500c9fd895465 Author: Gilles Chanteperdrix Date: Tue Sep 29 01:41:26 2015 +0200 rtdm/devices: avoid incomplete device cleanup when unregister_driver() is called from rtdm_dev_unregister(), __rtdm_put_device() has already decreased the driver reference count, so the result of atomic_dec_and_test() is always false and unregister_driver() does not finish the cleanup. Fix this by moving the atomic_dec_and_test() test to the only other call site of unregister_driver(): the rtdm_dev_regiter() error path. --- kernel/cobalt/rtdm/device.c |7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c index 1c602c2..9af2221 100644 --- a/kernel/cobalt/rtdm/device.c +++ b/kernel/cobalt/rtdm/device.c @@ -303,6 +303,7 @@ static int register_driver(struct rtdm_driver *drv) drv->named.major = MAJOR(rdev); atomic_set(&drv->refcount, 1); + done: drv->nb_statechange.notifier_call = state_change_notifier; drv->nb_statechange.priority = 0; @@ -321,9 +322,6 @@ 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_notifier_chain(&drv->nb_statechange); if (drv->device_flags & RTDM_NAMED_DEVICE) { @@ -452,7 +450,8 @@ fail: if (kdev) device_destroy(rtdm_class, rdev); - unregister_driver(drv); + if (atomic_dec_and_test(&drv->refcount)) + unregister_driver(drv); mutex_unlock(®ister_lock); ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://xenomai.org/mailman/listinfo/xenomai-git