Re: [EXT] Re: [PATCH] usb: roles: try to get/put all relevant modules

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

 



On Fri, Jan 19, 2024 at 03:23:50PM +0000, Xu Yang wrote:
> > What happens if the provider module is unloaded but then
> > usb_role_switch_put() is called after usb_role_switch_unregister()?
> > Won't there be a NULL pointer dereference inside the put_device() call?
> 
> The get_device() will be called after the user successfully get usb_role_switch
> device. So the resource of sw will continue to exist until usb_role_switch_put()
> is called.

But look: Your patch essentially prevents usb_role_switch_set_role() 
from running after the role-switch device has been unregistered.  But 
what if someone had already called usb_role_switch_set_role() before the 
device was unregistered?  Won't that eventually lead to problems if the 
provider's module is then unloaded from memory?

To put it another way, all those try_module_get() and module_put() calls 
were originally added to prevent a specific problem from occurring.  
Once you remove them, won't that problem be able to occur again?

Alan Stern




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux