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>
此提交包含在:
Simon Arlott
2009-11-21 15:33:51 +00:00
提交者 Greg Kroah-Hartman
父節點 5d0a9c7932
當前提交 9fc950d322
共有 3 個檔案被更改,包括 44 行新增20 行删除

查看文件

@@ -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_ */