linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sysfs: sysfs_update_group always fails and generates a WARNING CALL-trace
@ 2013-01-16  7:04 yanyg
  2013-01-16  7:15 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: yanyg @ 2013-01-16  7:04 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel

@sysfs_update_group@ always fails and borns a WARNING CALL-trace
if the group exists. BUT still now, no *reference* of this routine at all.

>From fe40df7d716658a1fbdab79768628c81d4363428 Mon Sep 17 00:00:00 2001
From: yanyg <yanyg02@gmail.com>
Date: Wed, 16 Jan 2013 11:25:15 +0800
Subject: [PATCH] sysfs-fixes:

@sysfs_update_group@ always fail and generates WARNING CALL trace.
fix @internal_create_group@ to avoid it.
---
 fs/sysfs/group.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index 2df555c..51fcf62 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -60,7 +60,7 @@ static int internal_create_group(struct kobject *kobj, int update,
 				 const struct attribute_group *grp)
 {
 	struct sysfs_dirent *sd;
-	int error;
+	int error, do_put = 0;
 
 	BUG_ON(!kobj || (!update && !kobj->sd));
 
@@ -73,9 +73,14 @@ static int internal_create_group(struct kobject *kobj, int update,
 		return -EINVAL;
 	}
 	if (grp->name) {
-		error = sysfs_create_subdir(kobj, grp->name, &sd);
-		if (error)
-			return error;
+		sd = sysfs_get_dirent(kobj->sd, NULL, grp->name);
+		if (sd) {
+			do_put = 1;
+		} else {
+			error = sysfs_create_subdir(kobj, grp->name, &sd);
+			if (error)
+				return error;
+		}
 	} else
 		sd = kobj->sd;
 	sysfs_get(sd);
@@ -85,6 +90,7 @@ static int internal_create_group(struct kobject *kobj, int update,
 			sysfs_remove_subdir(sd);
 	}
 	sysfs_put(sd);
+	if (do_put) sysfs_put(sd);
 	return error;
 }
 
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] sysfs: sysfs_update_group always fails and generates a WARNING CALL-trace
  2013-01-16  7:04 [PATCH] sysfs: sysfs_update_group always fails and generates a WARNING CALL-trace yanyg
@ 2013-01-16  7:15 ` Greg KH
  2013-01-16  7:40   ` yanyg02
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2013-01-16  7:15 UTC (permalink / raw)
  To: yanyg; +Cc: linux-kernel

On Wed, Jan 16, 2013 at 03:04:25PM +0800, yanyg wrote:
> @sysfs_update_group@ always fails and borns a WARNING CALL-trace
> if the group exists. BUT still now, no *reference* of this routine at all.

I don't understand.

> >From fe40df7d716658a1fbdab79768628c81d4363428 Mon Sep 17 00:00:00 2001
> From: yanyg <yanyg02@gmail.com>
> Date: Wed, 16 Jan 2013 11:25:15 +0800
> Subject: [PATCH] sysfs-fixes:
> 
> @sysfs_update_group@ always fail and generates WARNING CALL trace.
> fix @internal_create_group@ to avoid it.

Why did you embed the patch here, with the words above it?  I would have
to edit it to apply it :(

It's also not in a format I can apply (no signed-off-by: line.)

> ---
>  fs/sysfs/group.c |   14 ++++++++++----
>  1 files changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
> index 2df555c..51fcf62 100644
> --- a/fs/sysfs/group.c
> +++ b/fs/sysfs/group.c
> @@ -60,7 +60,7 @@ static int internal_create_group(struct kobject *kobj, int update,
>  				 const struct attribute_group *grp)
>  {
>  	struct sysfs_dirent *sd;
> -	int error;
> +	int error, do_put = 0;
>  
>  	BUG_ON(!kobj || (!update && !kobj->sd));
>  
> @@ -73,9 +73,14 @@ static int internal_create_group(struct kobject *kobj, int update,
>  		return -EINVAL;
>  	}
>  	if (grp->name) {
> -		error = sysfs_create_subdir(kobj, grp->name, &sd);
> -		if (error)
> -			return error;
> +		sd = sysfs_get_dirent(kobj->sd, NULL, grp->name);
> +		if (sd) {
> +			do_put = 1;
> +		} else {
> +			error = sysfs_create_subdir(kobj, grp->name, &sd);
> +			if (error)
> +				return error;
> +		}
>  	} else
>  		sd = kobj->sd;
>  	sysfs_get(sd);
> @@ -85,6 +90,7 @@ static int internal_create_group(struct kobject *kobj, int update,
>  			sysfs_remove_subdir(sd);
>  	}
>  	sysfs_put(sd);
> +	if (do_put) sysfs_put(sd);

Always run your patches through scripts/checkpatch.pl and fix the
problems it tells you about.

What code in the kernel is hitting this today?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sysfs: sysfs_update_group always fails and generates a WARNING CALL-trace
  2013-01-16  7:15 ` Greg KH
@ 2013-01-16  7:40   ` yanyg02
  0 siblings, 0 replies; 3+ messages in thread
From: yanyg02 @ 2013-01-16  7:40 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel

Sorry. I'm a fresh. This is my first patch commit. And still now *mutt* 
does not configured properly.

I will study howto and commit patch again. Sorry.

-------------------
> On Wed, Jan 16, 2013 at 03:04:25PM +0800, yanyg wrote:
>> @sysfs_update_group@ always fails and borns a WARNING CALL-trace
>> if the group exists. BUT still now, no *reference* of this routine at all.
> I don't understand.
OK, sysfs routine @sysfs_update_group@ *never* works properly
>
>> >From fe40df7d716658a1fbdab79768628c81d4363428 Mon Sep 17 00:00:00 2001
>> From: yanyg <yanyg02@gmail.com>
>> Date: Wed, 16 Jan 2013 11:25:15 +0800
>> Subject: [PATCH] sysfs-fixes:
>>
>> @sysfs_update_group@ always fail and generates WARNING CALL trace.
>> fix @internal_create_group@ to avoid it.
> Why did you embed the patch here, with the words above it?  I would have
> to edit it to apply it :(
>
> It's also not in a format I can apply (no signed-off-by: line.)
So sorry.
>
>> ---
>>   fs/sysfs/group.c |   14 ++++++++++----
>>   1 files changed, 10 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
>> index 2df555c..51fcf62 100644
>> --- a/fs/sysfs/group.c
>> +++ b/fs/sysfs/group.c
>> @@ -60,7 +60,7 @@ static int internal_create_group(struct kobject *kobj, int update,
>>   				 const struct attribute_group *grp)
>>   {
>>   	struct sysfs_dirent *sd;
>> -	int error;
>> +	int error, do_put = 0;
>>   
>>   	BUG_ON(!kobj || (!update && !kobj->sd));
>>   
>> @@ -73,9 +73,14 @@ static int internal_create_group(struct kobject *kobj, int update,
>>   		return -EINVAL;
>>   	}
>>   	if (grp->name) {
>> -		error = sysfs_create_subdir(kobj, grp->name, &sd);
>> -		if (error)
>> -			return error;
>> +		sd = sysfs_get_dirent(kobj->sd, NULL, grp->name);
>> +		if (sd) {
>> +			do_put = 1;
>> +		} else {
>> +			error = sysfs_create_subdir(kobj, grp->name, &sd);
>> +			if (error)
>> +				return error;
>> +		}
>>   	} else
>>   		sd = kobj->sd;
>>   	sysfs_get(sd);
>> @@ -85,6 +90,7 @@ static int internal_create_group(struct kobject *kobj, int update,
>>   			sysfs_remove_subdir(sd);
>>   	}
>>   	sysfs_put(sd);
>> +	if (do_put) sysfs_put(sd);
> Always run your patches through scripts/checkpatch.pl and fix the
> problems it tells you about.
>
> What code in the kernel is hitting this today?
I write a simply virtual block device driver which calls 
@sysfs_update_group@ to updates attributes and modes, it fails.
YOU can reproduce the bug by append @sysfs_update_group@ at below any of 
@sysfs_create_group@ call.
>
> thanks,
>
> greg k-h
>

So too sorry for my silly.

yanyg02

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-01-16  7:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-16  7:04 [PATCH] sysfs: sysfs_update_group always fails and generates a WARNING CALL-trace yanyg
2013-01-16  7:15 ` Greg KH
2013-01-16  7:40   ` yanyg02

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).