Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: cdc-acm: fix sysfs attribute registration bug

This patch (as950) fixes a bug in the cdc-acm driver. It doesn't keep
track of which interface (control or data) the sysfs attributes get
registered for, and as a result, during disconnect it will sometimes
attempt to remove the attributes from the wrong interface. The
left-over attributes can cause a crash later on, particularly if the driver
module has been unloaded.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Oliver Neukum <oneukum@suse.de>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


authored by

Alan Stern and committed by
Greg Kroah-Hartman
74da5d68 8c273033

+9 -3
+9 -3
drivers/usb/class/cdc-acm.c
··· 921 921 return -EINVAL; 922 922 } 923 923 } 924 + 925 + /* Accept probe requests only for the control interface */ 926 + if (intf != control_interface) 927 + return -ENODEV; 924 928 925 929 if (usb_interface_claimed(data_interface)) { /* valid in this context */ 926 930 dev_dbg(&intf->dev,"The data interface isn't available"); ··· 1113 1109 return; 1114 1110 } 1115 1111 if (acm->country_codes){ 1116 - device_remove_file(&intf->dev, &dev_attr_wCountryCodes); 1117 - device_remove_file(&intf->dev, &dev_attr_iCountryCodeRelDate); 1112 + device_remove_file(&acm->control->dev, 1113 + &dev_attr_wCountryCodes); 1114 + device_remove_file(&acm->control->dev, 1115 + &dev_attr_iCountryCodeRelDate); 1118 1116 } 1119 - device_remove_file(&intf->dev, &dev_attr_bmCapabilities); 1117 + device_remove_file(&acm->control->dev, &dev_attr_bmCapabilities); 1120 1118 acm->dev = NULL; 1121 1119 usb_set_intfdata(acm->control, NULL); 1122 1120 usb_set_intfdata(acm->data, NULL);