linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kobject: set state_initialized to 0 in kobject_cleanup
@ 2016-11-01 10:41 Songjun Wu
  2016-11-01 14:56 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Songjun Wu @ 2016-11-01 10:41 UTC (permalink / raw)
  To: gregkh, linux-kernel; +Cc: Songjun Wu

If state_initialized is not set to 0 when a kobject is
released, a device is registered, unregistered, and
registered again, the error below will occur.

kobject (dec04bb0): tried to init an initialized object,
something is seriously wrong.

Signed-off-by: Songjun Wu <songjun.wu@microchip.com>
---

 lib/kobject.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/kobject.c b/lib/kobject.c
index 445dcae..423af4e 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -639,6 +639,8 @@ static void kobject_cleanup(struct kobject *kobj)
 		kobject_del(kobj);
 	}
 
+	kobj->state_initialized = 0;
+
 	if (t && t->release) {
 		pr_debug("kobject: '%s' (%p): calling ktype release\n",
 			 kobject_name(kobj), kobj);
-- 
2.7.4

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

* Re: [PATCH] kobject: set state_initialized to 0 in kobject_cleanup
  2016-11-01 10:41 [PATCH] kobject: set state_initialized to 0 in kobject_cleanup Songjun Wu
@ 2016-11-01 14:56 ` Greg KH
  2016-11-02  1:29   ` Wu, Songjun
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2016-11-01 14:56 UTC (permalink / raw)
  To: Songjun Wu; +Cc: linux-kernel

On Tue, Nov 01, 2016 at 06:41:44PM +0800, Songjun Wu wrote:
> If state_initialized is not set to 0 when a kobject is
> released, a device is registered, unregistered, and
> registered again, the error below will occur.
> 
> kobject (dec04bb0): tried to init an initialized object,
> something is seriously wrong.

Yes, your code is wrong, don't try to change the kernel core to work
around it :)

That message is there for a reason, and this patch has been rejected
many times in the past.  kobjects can NOT ever be reused, and should
never be static (but yes, there are lots of in-kernel users with static
kobjects, they just never get reused...)

What code is emitting this message?  I'll be glad to help you fix it up
if you can point me at it.

thanks,

greg k-h

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

* Re: [PATCH] kobject: set state_initialized to 0 in kobject_cleanup
  2016-11-01 14:56 ` Greg KH
@ 2016-11-02  1:29   ` Wu, Songjun
  0 siblings, 0 replies; 3+ messages in thread
From: Wu, Songjun @ 2016-11-02  1:29 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel



On 11/1/2016 22:56, Greg KH wrote:
> On Tue, Nov 01, 2016 at 06:41:44PM +0800, Songjun Wu wrote:
>> If state_initialized is not set to 0 when a kobject is
>> released, a device is registered, unregistered, and
>> registered again, the error below will occur.
>>
>> kobject (dec04bb0): tried to init an initialized object,
>> something is seriously wrong.
>
> Yes, your code is wrong, don't try to change the kernel core to work
> around it :)
>
> That message is there for a reason, and this patch has been rejected
> many times in the past.  kobjects can NOT ever be reused, and should
> never be static (but yes, there are lots of in-kernel users with static
> kobjects, they just never get reused...)
>
> What code is emitting this message?  I'll be glad to help you fix it up
> if you can point me at it.
>
Thank you very much.
I will not use the static kobjects to fix the error.
:)
> thanks,
>
> greg k-h
>

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

end of thread, other threads:[~2016-11-02  1:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-01 10:41 [PATCH] kobject: set state_initialized to 0 in kobject_cleanup Songjun Wu
2016-11-01 14:56 ` Greg KH
2016-11-02  1:29   ` Wu, Songjun

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).