All of lore.kernel.org
 help / color / mirror / Atom feed
From: yanyg <yanyg02@gmail.com>
To: gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] sysfs: sysfs_update_group always fails and generates a WARNING CALL-trace
Date: Wed, 16 Jan 2013 15:04:25 +0800	[thread overview]
Message-ID: <20130116070425.GA3972@yvit> (raw)

@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


             reply	other threads:[~2013-01-16  7:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-16  7:04 yanyg [this message]
2013-01-16  7:15 ` [PATCH] sysfs: sysfs_update_group always fails and generates a WARNING CALL-trace Greg KH
2013-01-16  7:40   ` yanyg02

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130116070425.GA3972@yvit \
    --to=yanyg02@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.