aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/usb-serial.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/usb-serial.c')
-rw-r--r--drivers/usb/serial/usb-serial.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 02de3110fe94..475723c006f9 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -764,29 +764,39 @@ static int usb_serial_probe(struct usb_interface *interface,
764 if (usb_endpoint_is_bulk_in(endpoint)) { 764 if (usb_endpoint_is_bulk_in(endpoint)) {
765 /* we found a bulk in endpoint */ 765 /* we found a bulk in endpoint */
766 dev_dbg(ddev, "found bulk in on endpoint %d\n", i); 766 dev_dbg(ddev, "found bulk in on endpoint %d\n", i);
767 bulk_in_endpoint[num_bulk_in] = endpoint; 767 if (num_bulk_in < MAX_NUM_PORTS) {
768 ++num_bulk_in; 768 bulk_in_endpoint[num_bulk_in] = endpoint;
769 ++num_bulk_in;
770 }
769 } 771 }
770 772
771 if (usb_endpoint_is_bulk_out(endpoint)) { 773 if (usb_endpoint_is_bulk_out(endpoint)) {
772 /* we found a bulk out endpoint */ 774 /* we found a bulk out endpoint */
773 dev_dbg(ddev, "found bulk out on endpoint %d\n", i); 775 dev_dbg(ddev, "found bulk out on endpoint %d\n", i);
774 bulk_out_endpoint[num_bulk_out] = endpoint; 776 if (num_bulk_out < MAX_NUM_PORTS) {
775 ++num_bulk_out; 777 bulk_out_endpoint[num_bulk_out] = endpoint;
778 ++num_bulk_out;
779 }
776 } 780 }
777 781
778 if (usb_endpoint_is_int_in(endpoint)) { 782 if (usb_endpoint_is_int_in(endpoint)) {
779 /* we found a interrupt in endpoint */ 783 /* we found a interrupt in endpoint */
780 dev_dbg(ddev, "found interrupt in on endpoint %d\n", i); 784 dev_dbg(ddev, "found interrupt in on endpoint %d\n", i);
781 interrupt_in_endpoint[num_interrupt_in] = endpoint; 785 if (num_interrupt_in < MAX_NUM_PORTS) {
782 ++num_interrupt_in; 786 interrupt_in_endpoint[num_interrupt_in] =
787 endpoint;
788 ++num_interrupt_in;
789 }
783 } 790 }
784 791
785 if (usb_endpoint_is_int_out(endpoint)) { 792 if (usb_endpoint_is_int_out(endpoint)) {
786 /* we found an interrupt out endpoint */ 793 /* we found an interrupt out endpoint */
787 dev_dbg(ddev, "found interrupt out on endpoint %d\n", i); 794 dev_dbg(ddev, "found interrupt out on endpoint %d\n", i);
788 interrupt_out_endpoint[num_interrupt_out] = endpoint; 795 if (num_interrupt_out < MAX_NUM_PORTS) {
789 ++num_interrupt_out; 796 interrupt_out_endpoint[num_interrupt_out] =
797 endpoint;
798 ++num_interrupt_out;
799 }
790 } 800 }
791 } 801 }
792 802
@@ -809,8 +819,10 @@ static int usb_serial_probe(struct usb_interface *interface,
809 if (usb_endpoint_is_int_in(endpoint)) { 819 if (usb_endpoint_is_int_in(endpoint)) {
810 /* we found a interrupt in endpoint */ 820 /* we found a interrupt in endpoint */
811 dev_dbg(ddev, "found interrupt in for Prolific device on separate interface\n"); 821 dev_dbg(ddev, "found interrupt in for Prolific device on separate interface\n");
812 interrupt_in_endpoint[num_interrupt_in] = endpoint; 822 if (num_interrupt_in < MAX_NUM_PORTS) {
813 ++num_interrupt_in; 823 interrupt_in_endpoint[num_interrupt_in] = endpoint;
824 ++num_interrupt_in;
825 }
814 } 826 }
815 } 827 }
816 } 828 }
@@ -850,6 +862,11 @@ static int usb_serial_probe(struct usb_interface *interface,
850 num_ports = type->num_ports; 862 num_ports = type->num_ports;
851 } 863 }
852 864
865 if (num_ports > MAX_NUM_PORTS) {
866 dev_warn(ddev, "too many ports requested: %d\n", num_ports);
867 num_ports = MAX_NUM_PORTS;
868 }
869
853 serial->num_ports = num_ports; 870 serial->num_ports = num_ports;
854 serial->num_bulk_in = num_bulk_in; 871 serial->num_bulk_in = num_bulk_in;
855 serial->num_bulk_out = num_bulk_out; 872 serial->num_bulk_out = num_bulk_out;