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

USB: serial: propagate late probe errors

Propagate errnos for late probe errors (e.g. -ENOMEM on allocation
failures) instead of always returning -EIO.

Note that some drivers are currently returning -ENODEV from their attach
callbacks when a device is not supported, but this has also been mapped
to -EIO.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>

+12 -11
+12 -11
drivers/usb/serial/usb-serial.c
··· 962 962 dev_dbg(ddev, "setting up %d port structure(s)\n", max_endpoints); 963 963 for (i = 0; i < max_endpoints; ++i) { 964 964 port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL); 965 - if (!port) 966 - goto probe_error; 965 + if (!port) { 966 + retval = -ENOMEM; 967 + goto err_free_epds; 968 + } 967 969 tty_port_init(&port->port); 968 970 port->port.ops = &serial_port_ops; 969 971 port->serial = serial; ··· 986 984 for (i = 0; i < epds->num_bulk_in; ++i) { 987 985 retval = setup_port_bulk_in(serial->port[i], epds->bulk_in[i]); 988 986 if (retval) 989 - goto probe_error; 987 + goto err_free_epds; 990 988 } 991 989 992 990 for (i = 0; i < epds->num_bulk_out; ++i) { 993 991 retval = setup_port_bulk_out(serial->port[i], 994 992 epds->bulk_out[i]); 995 993 if (retval) 996 - goto probe_error; 994 + goto err_free_epds; 997 995 } 998 996 999 997 if (serial->type->read_int_callback) { ··· 1001 999 retval = setup_port_interrupt_in(serial->port[i], 1002 1000 epds->interrupt_in[i]); 1003 1001 if (retval) 1004 - goto probe_error; 1002 + goto err_free_epds; 1005 1003 } 1006 1004 } else if (epds->num_interrupt_in) { 1007 1005 dev_dbg(ddev, "The device claims to support interrupt in transfers, but read_int_callback is not defined\n"); ··· 1012 1010 retval = setup_port_interrupt_out(serial->port[i], 1013 1011 epds->interrupt_out[i]); 1014 1012 if (retval) 1015 - goto probe_error; 1013 + goto err_free_epds; 1016 1014 } 1017 1015 } else if (epds->num_interrupt_out) { 1018 1016 dev_dbg(ddev, "The device claims to support interrupt out transfers, but write_int_callback is not defined\n"); ··· 1024 1022 if (type->attach) { 1025 1023 retval = type->attach(serial); 1026 1024 if (retval < 0) 1027 - goto probe_error; 1025 + goto err_free_epds; 1028 1026 serial->attached = 1; 1029 1027 if (retval > 0) { 1030 1028 /* quietly accept this device, but don't bind to a ··· 1036 1034 serial->attached = 1; 1037 1035 } 1038 1036 1039 - if (allocate_minors(serial, num_ports)) { 1037 + retval = allocate_minors(serial, num_ports); 1038 + if (retval) { 1040 1039 dev_err(ddev, "No more free serial minor numbers\n"); 1041 - goto probe_error; 1040 + goto err_free_epds; 1042 1041 } 1043 1042 1044 1043 /* register all of the individual ports with the driver core */ ··· 1061 1058 module_put(type->driver.owner); 1062 1059 return 0; 1063 1060 1064 - probe_error: 1065 - retval = -EIO; 1066 1061 err_free_epds: 1067 1062 kfree(epds); 1068 1063 err_put_serial: