aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Cook <tony-cook@bigpond.com>2009-04-18 09:12:18 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-04-23 17:15:28 -0400
commit37768adf9a1d49aeac0db1ba3dc28b3274b7b789 (patch)
treefd68c1ba85729b0f217d9c379a64dab10c58bdb8
parente9b8cffa923e8eb3fe70ea05d3fcfffc90a71a57 (diff)
USB: fix mos7840 problem with minor numbers
This patch fixes a problem with any mos7840 device where the use of the field "minor" before it is initialised results in all the devices being overlaid in memory (minor = 0 for all instances) Contributed by: Phillip Branch Signed-off-by: Tony Cook <tony-cook@bigpond.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/usb/serial/mos7840.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 567985b7013e..499b7b82a0ec 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -38,7 +38,7 @@
38/* 38/*
39 * Version Information 39 * Version Information
40 */ 40 */
41#define DRIVER_VERSION "1.3.1" 41#define DRIVER_VERSION "1.3.2"
42#define DRIVER_DESC "Moschip 7840/7820 USB Serial Driver" 42#define DRIVER_DESC "Moschip 7840/7820 USB Serial Driver"
43 43
44/* 44/*
@@ -2484,9 +2484,14 @@ static int mos7840_startup(struct usb_serial *serial)
2484 mos7840_set_port_private(serial->port[i], mos7840_port); 2484 mos7840_set_port_private(serial->port[i], mos7840_port);
2485 spin_lock_init(&mos7840_port->pool_lock); 2485 spin_lock_init(&mos7840_port->pool_lock);
2486 2486
2487 mos7840_port->port_num = ((serial->port[i]->number - 2487 /* minor is not initialised until later by
2488 (serial->port[i]->serial->minor)) + 2488 * usb-serial.c:get_free_serial() and cannot therefore be used
2489 1); 2489 * to index device instances */
2490 mos7840_port->port_num = i + 1;
2491 dbg ("serial->port[i]->number = %d", serial->port[i]->number);
2492 dbg ("serial->port[i]->serial->minor = %d", serial->port[i]->serial->minor);
2493 dbg ("mos7840_port->port_num = %d", mos7840_port->port_num);
2494 dbg ("serial->minor = %d", serial->minor);
2490 2495
2491 if (mos7840_port->port_num == 1) { 2496 if (mos7840_port->port_num == 1) {
2492 mos7840_port->SpRegOffset = 0x0; 2497 mos7840_port->SpRegOffset = 0x0;
@@ -2697,13 +2702,16 @@ static void mos7840_shutdown(struct usb_serial *serial)
2697 2702
2698 for (i = 0; i < serial->num_ports; ++i) { 2703 for (i = 0; i < serial->num_ports; ++i) {
2699 mos7840_port = mos7840_get_port_private(serial->port[i]); 2704 mos7840_port = mos7840_get_port_private(serial->port[i]);
2700 spin_lock_irqsave(&mos7840_port->pool_lock, flags); 2705 dbg ("mos7840_port %d = %p", i, mos7840_port);
2701 mos7840_port->zombie = 1; 2706 if (mos7840_port) {
2702 spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); 2707 spin_lock_irqsave(&mos7840_port->pool_lock, flags);
2703 usb_kill_urb(mos7840_port->control_urb); 2708 mos7840_port->zombie = 1;
2704 kfree(mos7840_port->ctrl_buf); 2709 spin_unlock_irqrestore(&mos7840_port->pool_lock, flags);
2705 kfree(mos7840_port->dr); 2710 usb_kill_urb(mos7840_port->control_urb);
2706 kfree(mos7840_port); 2711 kfree(mos7840_port->ctrl_buf);
2712 kfree(mos7840_port->dr);
2713 kfree(mos7840_port);
2714 }
2707 mos7840_set_port_private(serial->port[i], NULL); 2715 mos7840_set_port_private(serial->port[i], NULL);
2708 } 2716 }
2709 2717