Project

General

Profile

Feature #3306

132: Usb device reference counting with usb_get_dev/usb_put_dev and interface_to_usbdev

Added by Mikhail Mandrykin about 7 years ago. Updated almost 5 years ago.

Status:
Open
Priority:
Normal
Start date:
07/30/2012
Due date:
% Done:

0%

Estimated time:
Published in build:

Description

Proper reference counting should be performed for struct usb_device with the use of functions usb_get_dev/usb_put_dev.

/**
 * 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.

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

History

#1

Updated by Mikhail Mandrykin about 7 years ago

  • Assignee set to Mikhail Mandrykin
#2

Updated by Mikhail Mandrykin about 7 years ago

  • Status changed from New to Open
#3

Updated by Vitaly Mordan about 5 years ago

Unnecessary header
#include <linux/usb.h>
may cause Aspectator to failed at 'instrumentation' stage.

#4

Updated by Vadim Mutilin almost 5 years ago

  • Description updated (diff)

Also available in: Atom PDF