mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@suse.de>,
	David Miller <davem@davemloft.net>,
	Kay Sievers <kay.sievers@vrfy.org>,
	"Rafael J. Wysocki" <rjw@sisk.pl>, Tejun Heo <htejun@gmail.com>
Subject: [PATCH 2/6] kobject: check for duplicate names in kobject_rename
Date: Tue, 30 Oct 2007 22:11:41 -0700	[thread overview]
Message-ID: <1193807505-3821-2-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <1193807505-3821-1-git-send-email-gregkh@suse.de>

This should catch any duplicate names before we try to tell sysfs to
rename the object.  This happens a lot with older versions of udev and
the network rename scripts.

Cc: David Miller <davem@davemloft.net>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Tejun Heo <htejun@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 lib/kobject.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/lib/kobject.c b/lib/kobject.c
index 03d4036..a7e3bf4 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -308,6 +308,19 @@ int kobject_rename(struct kobject * kobj, const char *new_name)
 	if (!kobj->parent)
 		return -EINVAL;
 
+	/* see if this name is already in use */
+	if (kobj->kset) {
+		struct kobject *temp_kobj;
+		temp_kobj = kset_find_obj(kobj->kset, new_name);
+		if (temp_kobj) {
+			printk(KERN_WARNING "kobject '%s' can not be renamed "
+			       "to '%s' as '%s' is already in existance.\n",
+			       kobject_name(kobj), new_name, new_name);
+			kobject_put(temp_kobj);
+			return -EINVAL;
+		}
+	}
+
 	devpath = kobject_get_path(kobj, GFP_KERNEL);
 	if (!devpath) {
 		error = -ENOMEM;
-- 
1.5.3.4


  reply	other threads:[~2007-10-31  5:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-31  5:09 [GIT PATCH] driver core fixes for 2.6.24-rc1 Greg KH
2007-10-31  5:11 ` [PATCH 1/6] Driver core: remove class_device_*_bin_file Greg Kroah-Hartman
2007-10-31  5:11   ` Greg Kroah-Hartman [this message]
2007-10-31  5:11     ` [PATCH 3/6] sysfs: make sysfs_{get,put}_active() static Greg Kroah-Hartman
2007-10-31  5:11       ` [PATCH 4/6] Driver Core: fix bug in device_rename() for SYSFS_DEPRECATED=y Greg Kroah-Hartman
2007-10-31  5:11         ` [PATCH 5/6] fix typo in SubmittingPatches Greg Kroah-Hartman
2007-10-31  5:11           ` [PATCH 6/6] add SubmittingPatches to Documentation/ja_JP Greg Kroah-Hartman
2007-10-31  9:17           ` [PATCH 5/6] fix typo in SubmittingPatches Andy Whitcroft
2007-10-31 17:26   ` [PATCH 1/6] Driver core: remove class_device_*_bin_file Tony Luck
2007-10-31 18:44     ` Greg KH

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=1193807505-3821-2-git-send-email-gregkh@suse.de \
    --to=gregkh@suse.de \
    --cc=davem@davemloft.net \
    --cc=htejun@gmail.com \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rjw@sisk.pl \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome