From 9fc950d322380dda8e9bc8debe89766085e7a0eb Mon Sep 17 00:00:00 2001 From: Simon Arlott Date: Sat, 21 Nov 2009 15:33:51 +0000 Subject: 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 Signed-off-by: Greg Kroah-Hartman --- drivers/usb/atm/usbatm.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/usb/atm/usbatm.c') diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c index fbea8563df1e..40380434ba96 100644 --- a/drivers/usb/atm/usbatm.c +++ b/drivers/usb/atm/usbatm.c @@ -1333,6 +1333,7 @@ void usbatm_usb_disconnect(struct usb_interface *intf) if (instance->atm_dev) { sysfs_remove_link(&instance->atm_dev->class_dev.kobj, "device"); atm_dev_deregister(instance->atm_dev); + instance->atm_dev = NULL; } usbatm_put_instance(instance); /* taken in usbatm_usb_probe */ -- cgit v1.2.3 From 08add0c780b9f5c35de49d83abb7a4e14a9cd457 Mon Sep 17 00:00:00 2001 From: Thiago Farina Date: Mon, 11 Jan 2010 20:45:26 -0500 Subject: USB: atm: Use FIELD_SIZEOF, trivial cleanup. Signed-off-by: Thiago Farina Signed-off-by: Greg Kroah-Hartman --- drivers/usb/atm/usbatm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/atm/usbatm.c') diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c index 40380434ba96..9b53e8df4648 100644 --- a/drivers/usb/atm/usbatm.c +++ b/drivers/usb/atm/usbatm.c @@ -1349,7 +1349,7 @@ static int __init usbatm_usb_init(void) { dbg("%s: driver version %s", __func__, DRIVER_VERSION); - if (sizeof(struct usbatm_control) > sizeof(((struct sk_buff *) 0)->cb)) { + if (sizeof(struct usbatm_control) > FIELD_SIZEOF(struct sk_buff, cb)) { printk(KERN_ERR "%s unusable with this kernel!\n", usbatm_driver_name); return -EIO; } -- cgit v1.2.3