Re: [linux-usb-devel] [PATCH] back out sysfs reference count change

Alan Stern
2004-04-01T14:56:33Z

On Thu, 1 Apr 2004, Maneesh Soni wrote:

> On Wed, Mar 31, 2004 at 10:11:37AM -0500, Alan Stern wrote:
> >
> > Here's a suggestion. At the start of check_perm() grab the dentry
> > semaphore, then check whether d_fsdata is NULL, if it isn't then do the
> > kobject_get(), then unlock the semaphore.
> >
>
> I have tried this with no luck. I still get
> (Badness in kobject_get at lib/kobject.c:42) which means it is not correct fix.

Did you remember to set dentry->d_fsdata to NULL? This has to be done in
sysfs_remove_dir() sometime during the period when dentry->d_inode->i_sem
is held. Right now the pointer to the kobject never gets erased. That
Badness message is an indication that you are using a valid pointer to a
kobject whose refcount is 0.

Alan Stern