Project

General

Profile

Actions

Feature #3306

open

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

Added by Mikhail Mandrykin over 11 years ago. Updated over 9 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

Actions #1

Updated by Mikhail Mandrykin over 11 years ago

  • Assignee set to Mikhail Mandrykin
Actions #2

Updated by Mikhail Mandrykin over 11 years ago

  • Status changed from New to Open
Actions #3

Updated by Vitaly Mordan over 9 years ago

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

Actions #4

Updated by Vadim Mutilin over 9 years ago

  • Description updated (diff)
Actions

Also available in: Atom PDF