Project

General

Profile

Feature #3306

Updated by Vadim Mutilin over 9 years ago

Proper reference counting should be performed for @struct usb_device@ with the use of functions @usb_get_dev@/@usb_put_dev@. 
 <pre> 
 /** 
  * usb_get_dev - increments the reference count of the usb device structure 
  * @dev: the device being referenced 
  * 
  * Each live reference to a device should be refcounted. 
  * 
  * Drivers for USB interfaces should normally record such references in 
  * their probe() methods, when they bind to an interface, and release 
  * them by calling usb_put_dev(), in their disconnect() methods. 
 </pre> 
 Usually the reference count is increased in @probe()@ handler and decreased in @disconnect()@/@exit()@ handler. It look like @interface_to_usbdev()@ macro is often used in @probe()@ handler to get the reference to @usb_device@ by the reference to @usb_interface@. 

 So the rule may be initially formalized in the following way: after acquiring a reference to @struct usb_device@ with @usb_interface@ macro one should increase the corresponding reference counter with @usb_get_dev@ and then decrease it with @usb_put_dev@ at finalization. 

 *Links* 

 Sample bugfixes "927c3fa":https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?id=927c3fa

Back