lkml.org 
[lkml]   [2014]   [Nov]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Subject: [PATCH] kobject: fix the race between kobject_del and get_device_parent
Hello,

Sorry about the delay.

On Wed, Oct 22, 2014 at 04:07:44PM +0800, Weng Meiling wrote:
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 28b808c..645eacf 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -724,12 +724,12 @@ class_dir_create_and_add(struct class *class, struct kobject *parent_kobj)
> return &dir->kobj;
> }
>
> +static DEFINE_MUTEX(gdp_mutex);
>
> static struct kobject *get_device_parent(struct device *dev,
> struct device *parent)
> {
> if (dev->class) {
> - static DEFINE_MUTEX(gdp_mutex);
> struct kobject *kobj = NULL;
> struct kobject *parent_kobj;
> struct kobject *k;
> @@ -793,7 +793,9 @@ static void cleanup_glue_dir(struct device *dev, struct kobject *glue_dir)
> glue_dir->kset != &dev->class->p->glue_dirs)
> return;
>
> + mutex_lock(&gdp_mutex);
> kobject_put(glue_dir);
> + mutex_unlock(&gdp_mutex);

So, yeah, this looks like a correct approach; however, do we even need
to clear the glue directories? What's the downside of just keeping
them around once created?

Thanks.

--
tejun


\
 
 \ /
  Last update: 2014-11-04 21:01    [W:0.062 / U:0.720 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site