public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Keshavamurthy Anil S <anil.s.keshavamurthy@intel.com>
To: Greg KH <greg@kroah.com>, Len Brown <len.brown@intel.com>
Cc: Keshavamurthy Anil S <anil.s.keshavamurthy@intel.com>,
	Hotplug List <linux-hotplug-devel@lists.sourceforge.net>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	ACPI Developer <acpi-devel@lists.sourceforge.net>
Subject: Re: [PATCH] kobject: fix double kobject_put in kobject_unregister()
Date: Wed, 10 Nov 2004 17:54:15 -0800	[thread overview]
Message-ID: <20041110175415.B14535@unix-os.sc.intel.com> (raw)
In-Reply-To: <20041110225421.GA16785@kroah.com>; from greg@kroah.com on Wed, Nov 10, 2004 at 02:54:21PM -0800

On Wed, Nov 10, 2004 at 02:54:21PM -0800, Greg KH wrote:
> On Wed, Nov 10, 2004 at 02:19:23PM -0800, Keshavamurthy Anil S wrote:
> No, this is wrong.  Count the add and put in the sequence of:
> 	kobject_register()
> 	kobject_unregister()
> 
> they are balanced.

Yes, I agree now, but after investigating further here is what I have found.
If you think this is good, please ack this patch.


> 
> You mention you are seeing problems.  Have a trace?  Example code?

Here is what exactly happening. Please see the patch.
In ACPI, kobject_init() is called without initializing kobj.kset.
Due to this kset.kobj's refcount does not get incremented.
Again when we try to do kobject_unregister(), kset of the kobject
that is getting unregister is obtained and kset's kobject refcount
is decremented which was at teh first place never got inceremened.
Due to this kset's kobj's refcount is decremented with out getting
incremented and due to this bug, this kset.kobj is getting released.

Below fix fixes this problem. If you find this this Good patch,
please ack this patch. I am copying to Len too on this patch.


Signed-of-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
---

 linux-2.6.10-rc1-mm4-askeshav/drivers/acpi/scan.c |    3 +--
 1 files changed, 1 insertion(+), 2 deletions(-)

diff -puN drivers/acpi/scan.c~kobject_register_fix1 drivers/acpi/scan.c
--- linux-2.6.10-rc1-mm4/drivers/acpi/scan.c~kobject_register_fix1	2004-11-10 17:40:23.393117553 -0800
+++ linux-2.6.10-rc1-mm4-askeshav/drivers/acpi/scan.c	2004-11-10 17:41:45.844288418 -0800
@@ -112,13 +112,12 @@ static void acpi_device_register(struct 
 		list_add_tail(&device->wakeup_list,&acpi_wakeup_device_list);
 	spin_unlock(&acpi_device_lock);
 
-	kobject_init(&device->kobj);
 	strlcpy(device->kobj.name,device->pnp.bus_id,KOBJ_NAME_LEN);
 	if (parent)
 		device->kobj.parent = &parent->kobj;
 	device->kobj.ktype = &ktype_acpi_ns;
 	device->kobj.kset = &acpi_namespace_kset;
-	kobject_add(&device->kobj);
+	kobject_register(&device->kobj);
 	create_sysfs_device_files(device);
 }
 
_

      parent reply	other threads:[~2004-11-11  1:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-10 22:19 [PATCH] kobject: fix double kobject_put in kobject_unregister() Keshavamurthy Anil S
2004-11-10 22:30 ` Russell King
2004-11-10 22:39   ` Keshavamurthy Anil S
2004-11-10 22:54 ` Greg KH
2004-11-10 23:04   ` Keshavamurthy Anil S
2004-11-11  2:03     ` Keiichiro Tokunaga
2004-11-11  1:54   ` Keshavamurthy Anil S [this message]

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=20041110175415.B14535@unix-os.sc.intel.com \
    --to=anil.s.keshavamurthy@intel.com \
    --cc=acpi-devel@lists.sourceforge.net \
    --cc=greg@kroah.com \
    --cc=len.brown@intel.com \
    --cc=linux-hotplug-devel@lists.sourceforge.net \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox