aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/io_edgeport.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/io_edgeport.c')
-rw-r--r--drivers/usb/serial/io_edgeport.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index b606c5968102..c28f1f6902c3 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -142,7 +142,7 @@ struct edgeport_port {
142 142
143/* This structure holds all of the individual device information */ 143/* This structure holds all of the individual device information */
144struct edgeport_serial { 144struct edgeport_serial {
145 char name[MAX_NAME_LEN+1]; /* string name of this device */ 145 char name[MAX_NAME_LEN+2]; /* string name of this device */
146 146
147 struct edge_manuf_descriptor manuf_descriptor; /* the manufacturer descriptor */ 147 struct edge_manuf_descriptor manuf_descriptor; /* the manufacturer descriptor */
148 struct edge_boot_descriptor boot_descriptor; /* the boot firmware descriptor */ 148 struct edge_boot_descriptor boot_descriptor; /* the boot firmware descriptor */
@@ -270,7 +270,7 @@ static void get_manufacturing_desc (struct edgeport_serial *edge_serial);
270static void get_boot_desc (struct edgeport_serial *edge_serial); 270static void get_boot_desc (struct edgeport_serial *edge_serial);
271static void load_application_firmware (struct edgeport_serial *edge_serial); 271static void load_application_firmware (struct edgeport_serial *edge_serial);
272 272
273static void unicode_to_ascii (char *string, __le16 *unicode, int unicode_size); 273static void unicode_to_ascii(char *string, int buflen, __le16 *unicode, int unicode_size);
274 274
275 275
276// ************************************************************************ 276// ************************************************************************
@@ -373,7 +373,7 @@ static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial)
373 * Get string descriptor from device * 373 * Get string descriptor from device *
374 * * 374 * *
375 ************************************************************************/ 375 ************************************************************************/
376static int get_string (struct usb_device *dev, int Id, char *string) 376static int get_string (struct usb_device *dev, int Id, char *string, int buflen)
377{ 377{
378 struct usb_string_descriptor StringDesc; 378 struct usb_string_descriptor StringDesc;
379 struct usb_string_descriptor *pStringDesc; 379 struct usb_string_descriptor *pStringDesc;
@@ -395,7 +395,7 @@ static int get_string (struct usb_device *dev, int Id, char *string)
395 return 0; 395 return 0;
396 } 396 }
397 397
398 unicode_to_ascii(string, pStringDesc->wData, pStringDesc->bLength/2-1); 398 unicode_to_ascii(string, buflen, pStringDesc->wData, pStringDesc->bLength/2);
399 399
400 kfree(pStringDesc); 400 kfree(pStringDesc);
401 return strlen(string); 401 return strlen(string);
@@ -2564,16 +2564,20 @@ static void change_port_settings (struct edgeport_port *edge_port, struct termio
2564 * ASCII range, but it's only for debugging... 2564 * ASCII range, but it's only for debugging...
2565 * NOTE: expects the unicode in LE format 2565 * NOTE: expects the unicode in LE format
2566 ****************************************************************************/ 2566 ****************************************************************************/
2567static void unicode_to_ascii (char *string, __le16 *unicode, int unicode_size) 2567static void unicode_to_ascii(char *string, int buflen, __le16 *unicode, int unicode_size)
2568{ 2568{
2569 int i; 2569 int i;
2570 2570
2571 if (unicode_size <= 0) 2571 if (buflen <= 0) /* never happens, but... */
2572 return; 2572 return;
2573 --buflen; /* space for nul */
2573 2574
2574 for (i = 0; i < unicode_size; ++i) 2575 for (i = 0; i < unicode_size; i++) {
2576 if (i >= buflen)
2577 break;
2575 string[i] = (char)(le16_to_cpu(unicode[i])); 2578 string[i] = (char)(le16_to_cpu(unicode[i]));
2576 string[unicode_size] = 0x00; 2579 }
2580 string[i] = 0x00;
2577} 2581}
2578 2582
2579 2583
@@ -2603,11 +2607,17 @@ static void get_manufacturing_desc (struct edgeport_serial *edge_serial)
2603 dbg(" BoardRev: %d", edge_serial->manuf_descriptor.BoardRev); 2607 dbg(" BoardRev: %d", edge_serial->manuf_descriptor.BoardRev);
2604 dbg(" NumPorts: %d", edge_serial->manuf_descriptor.NumPorts); 2608 dbg(" NumPorts: %d", edge_serial->manuf_descriptor.NumPorts);
2605 dbg(" DescDate: %d/%d/%d", edge_serial->manuf_descriptor.DescDate[0], edge_serial->manuf_descriptor.DescDate[1], edge_serial->manuf_descriptor.DescDate[2]+1900); 2609 dbg(" DescDate: %d/%d/%d", edge_serial->manuf_descriptor.DescDate[0], edge_serial->manuf_descriptor.DescDate[1], edge_serial->manuf_descriptor.DescDate[2]+1900);
2606 unicode_to_ascii (string, edge_serial->manuf_descriptor.SerialNumber, edge_serial->manuf_descriptor.SerNumLength/2-1); 2610 unicode_to_ascii(string, 30,
2611 edge_serial->manuf_descriptor.SerialNumber,
2612 edge_serial->manuf_descriptor.SerNumLength/2);
2607 dbg(" SerialNumber: %s", string); 2613 dbg(" SerialNumber: %s", string);
2608 unicode_to_ascii (string, edge_serial->manuf_descriptor.AssemblyNumber, edge_serial->manuf_descriptor.AssemblyNumLength/2-1); 2614 unicode_to_ascii(string, 30,
2615 edge_serial->manuf_descriptor.AssemblyNumber,
2616 edge_serial->manuf_descriptor.AssemblyNumLength/2);
2609 dbg(" AssemblyNumber: %s", string); 2617 dbg(" AssemblyNumber: %s", string);
2610 unicode_to_ascii (string, edge_serial->manuf_descriptor.OemAssyNumber, edge_serial->manuf_descriptor.OemAssyNumLength/2-1); 2618 unicode_to_ascii(string, 30,
2619 edge_serial->manuf_descriptor.OemAssyNumber,
2620 edge_serial->manuf_descriptor.OemAssyNumLength/2);
2611 dbg(" OemAssyNumber: %s", string); 2621 dbg(" OemAssyNumber: %s", string);
2612 dbg(" UartType: %d", edge_serial->manuf_descriptor.UartType); 2622 dbg(" UartType: %d", edge_serial->manuf_descriptor.UartType);
2613 dbg(" IonPid: %d", edge_serial->manuf_descriptor.IonPid); 2623 dbg(" IonPid: %d", edge_serial->manuf_descriptor.IonPid);
@@ -2735,11 +2745,11 @@ static int edge_startup (struct usb_serial *serial)
2735 usb_set_serial_data(serial, edge_serial); 2745 usb_set_serial_data(serial, edge_serial);
2736 2746
2737 /* get the name for the device from the device */ 2747 /* get the name for the device from the device */
2738 if ( (i = get_string(dev, dev->descriptor.iManufacturer, &edge_serial->name[0])) != 0) { 2748 i = get_string(dev, dev->descriptor.iManufacturer,
2739 edge_serial->name[i-1] = ' '; 2749 &edge_serial->name[0], MAX_NAME_LEN+1);
2740 } 2750 edge_serial->name[i++] = ' ';
2741 2751 get_string(dev, dev->descriptor.iProduct,
2742 get_string(dev, dev->descriptor.iProduct, &edge_serial->name[i]); 2752 &edge_serial->name[i], MAX_NAME_LEN+2 - i);
2743 2753
2744 dev_info(&serial->dev->dev, "%s detected\n", edge_serial->name); 2754 dev_info(&serial->dev->dev, "%s detected\n", edge_serial->name);
2745 2755