lkml.org 
[lkml]   [2015]   [May]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 002/003] Attempt to cope with device changes and delayed kobject deallocation
Avoid attempts to use device parents with zero refcounts

Signed-off-by: Richard Watts <rrw@kynesim.co.uk>
---
drivers/base/core.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 21d1303..207fbb2 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -762,7 +762,13 @@ static struct kobject *get_device_parent(struct
device *dev,
spin_lock(&dev->class->p->glue_dirs.list_lock);
list_for_each_entry(k, &dev->class->p->glue_dirs.list, entry)
if (k->parent == parent_kobj) {
- kobj = kobject_get(k);
+ /* Be careful: an old parent may still
+ * be in this list awaiting deletion, despite
+ * having a refcount of 0. We don't want to
+ * add it here and then have some other thread
+ * delete it.
+ */
+ kobj = kobject_get_unless_zero(k);
break;
}
spin_unlock(&dev->class->p->glue_dirs.list_lock);
--
1.9.1


\
 
 \ /
  Last update: 2015-05-19 18:01    [W:1.471 / U:0.540 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site