Skip to content

Commit

Permalink
usb-core: Set intfdata to NULL if a driver's probe method failed
Browse files Browse the repository at this point in the history
Ensure that intfdata always is NULL if no driver is bound:
1) drvdata is for a driver to store a pointer to driver specific data
2) If no driver is bound, there is no driver specific data associated with
   the device
3) Thus logically drvdata should be NULL if no driver is bound.

We already set intfdata to NULL when a driver is unbound, to ensure that
intfdata will be NULL even if the drivers disconnect method does not properly
clear it. This ensures that intfdata will also be NULL after a failed probe,
even if the driver's probe method left a (likely dangling) pointer in there.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Hans de Goede authored and Greg Kroah-Hartman committed Jun 13, 2012
1 parent 4d4847b commit e714fad
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/usb/core/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ static int usb_probe_interface(struct device *dev)
return error;

err:
usb_set_intfdata(intf, NULL);
intf->needs_remote_wakeup = 0;
intf->condition = USB_INTERFACE_UNBOUND;
usb_cancel_queued_reset(intf);
Expand Down

0 comments on commit e714fad

Please sign in to comment.