Re: device_remove_file and disconnect

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 29, 2005 at 10:17:59PM +0200, matthieu castet wrote:
> Hi,
> 
> Greg KH wrote:
> >On Wed, Jun 29, 2005 at 06:59:00PM +0200, matthieu castet wrote:
> >
> >>Hi,
> >>
> >>I have a question about sysfs interface.
> >>
> >>If you open a sysfs file created by a module, then remove it (rmmoding 
> >>the module that create this sysfs file), then try to read the opened 
> >>file, you often get strange result (segdefault or oppps).
> >
> >
> >What file did you do this for?  The module count should be incremented
> >if you do this, to prevent the module from being unloaded.
> >
> Ok, but if we unplug a device, then disconnect will be called even if we 
> opened a sysfs file.

Yes but the device structure will still be in memory, so you will be ok.

> Couldn't be a race between the moment we read our private data and check 
> it is valid and the moment we use it :
> 
> Process A (read/write sysfs file) 		Process B (disconnect)
> recover our private data from struct device
> check it is valid
> 						free our private data
> do operation on private data

No, you should not be freeing your private data on your own.  You should
do that in the device release function.

Again, any specific place in the kernel that you see not doing this?

thanks,

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux