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>
This commit is contained in:
parent
e9b8cffa92
commit
37768adf9a
1 changed files with 19 additions and 11 deletions
|
@ -38,7 +38,7 @@
|
||||||
/*
|
/*
|
||||||
* Version Information
|
* Version Information
|
||||||
*/
|
*/
|
||||||
#define DRIVER_VERSION "1.3.1"
|
#define DRIVER_VERSION "1.3.2"
|
||||||
#define DRIVER_DESC "Moschip 7840/7820 USB Serial Driver"
|
#define DRIVER_DESC "Moschip 7840/7820 USB Serial Driver"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2484,9 +2484,14 @@ static int mos7840_startup(struct usb_serial *serial)
|
||||||
mos7840_set_port_private(serial->port[i], mos7840_port);
|
mos7840_set_port_private(serial->port[i], mos7840_port);
|
||||||
spin_lock_init(&mos7840_port->pool_lock);
|
spin_lock_init(&mos7840_port->pool_lock);
|
||||||
|
|
||||||
mos7840_port->port_num = ((serial->port[i]->number -
|
/* minor is not initialised until later by
|
||||||
(serial->port[i]->serial->minor)) +
|
* usb-serial.c:get_free_serial() and cannot therefore be used
|
||||||
1);
|
* to index device instances */
|
||||||
|
mos7840_port->port_num = i + 1;
|
||||||
|
dbg ("serial->port[i]->number = %d", serial->port[i]->number);
|
||||||
|
dbg ("serial->port[i]->serial->minor = %d", serial->port[i]->serial->minor);
|
||||||
|
dbg ("mos7840_port->port_num = %d", mos7840_port->port_num);
|
||||||
|
dbg ("serial->minor = %d", serial->minor);
|
||||||
|
|
||||||
if (mos7840_port->port_num == 1) {
|
if (mos7840_port->port_num == 1) {
|
||||||
mos7840_port->SpRegOffset = 0x0;
|
mos7840_port->SpRegOffset = 0x0;
|
||||||
|
@ -2697,6 +2702,8 @@ static void mos7840_shutdown(struct usb_serial *serial)
|
||||||
|
|
||||||
for (i = 0; i < serial->num_ports; ++i) {
|
for (i = 0; i < serial->num_ports; ++i) {
|
||||||
mos7840_port = mos7840_get_port_private(serial->port[i]);
|
mos7840_port = mos7840_get_port_private(serial->port[i]);
|
||||||
|
dbg ("mos7840_port %d = %p", i, mos7840_port);
|
||||||
|
if (mos7840_port) {
|
||||||
spin_lock_irqsave(&mos7840_port->pool_lock, flags);
|
spin_lock_irqsave(&mos7840_port->pool_lock, flags);
|
||||||
mos7840_port->zombie = 1;
|
mos7840_port->zombie = 1;
|
||||||
spin_unlock_irqrestore(&mos7840_port->pool_lock, flags);
|
spin_unlock_irqrestore(&mos7840_port->pool_lock, flags);
|
||||||
|
@ -2704,6 +2711,7 @@ static void mos7840_shutdown(struct usb_serial *serial)
|
||||||
kfree(mos7840_port->ctrl_buf);
|
kfree(mos7840_port->ctrl_buf);
|
||||||
kfree(mos7840_port->dr);
|
kfree(mos7840_port->dr);
|
||||||
kfree(mos7840_port);
|
kfree(mos7840_port);
|
||||||
|
}
|
||||||
mos7840_set_port_private(serial->port[i], NULL);
|
mos7840_set_port_private(serial->port[i], NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue