diff options
author | Simon Arlott <simon@fire.lp0.eu> | 2009-11-21 16:33:51 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-03-02 23:52:58 +0100 |
commit | 9fc950d322380dda8e9bc8debe89766085e7a0eb (patch) | |
tree | 50449ddbcc2cf883da8afe7ecfd1861c2441624f /drivers/usb/atm/usbatm.h | |
parent | USB: cxacru: check data length is not negative (diff) | |
download | linux-9fc950d322380dda8e9bc8debe89766085e7a0eb.tar.xz linux-9fc950d322380dda8e9bc8debe89766085e7a0eb.zip |
USB: cxacru: check device isn't being removed during sysfs calls
It is possible for usb_get_intfdata() to return NULL if
sysfs is accessed while the module is being unloaded or
the device is being removed.
Move the access code to an inline function in usbatm.h,
and return -ENODEV if any of the pointers are NULL.
It should not be possible for the instance data or atm
device to be invalid until after unbind() completes and
the sysfs attributes have been removed.
Signed-off-by: Simon Arlott <simon@fire.lp0.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/atm/usbatm.h')
-rw-r--r-- | drivers/usb/atm/usbatm.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/usb/atm/usbatm.h b/drivers/usb/atm/usbatm.h index f6f4508a9d42..0863f85fcc26 100644 --- a/drivers/usb/atm/usbatm.h +++ b/drivers/usb/atm/usbatm.h @@ -204,4 +204,19 @@ struct usbatm_data { struct urb *urbs[0]; }; +static inline void *to_usbatm_driver_data(struct usb_interface *intf) +{ + struct usbatm_data *usbatm_instance; + + if (intf == NULL) + return NULL; + + usbatm_instance = usb_get_intfdata(intf); + + if (usbatm_instance == NULL) /* set NULL before unbind() */ + return NULL; + + return usbatm_instance->driver_data; /* set NULL after unbind() */ +} + #endif /* _USBATM_H_ */ |