]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/parport/parport_serial.c
parport_serial: fix array overflow
[linux-2.6-omap-h63xx.git] / drivers / parport / parport_serial.c
index 78c0a269a2ba3e24200b0c13e72a70c99b978141..101ed49a2d15609937acbcf964274ed3f12d8360 100644 (file)
@@ -70,6 +70,8 @@ static int __devinit netmos_parallel_init(struct pci_dev *dev, struct parport_pc
         * parallel ports and <S> is the number of serial ports.
         */
        card->numports = (dev->subsystem_device & 0xf0) >> 4;
+       if (card->numports > ARRAY_SIZE(card->addr))
+               card->numports = ARRAY_SIZE(card->addr);
        return 0;
 }
 
@@ -77,7 +79,7 @@ static struct parport_pc_pci cards[] __devinitdata = {
        /* titan_110l */                { 1, { { 3, -1 }, } },
        /* titan_210l */                { 1, { { 3, -1 }, } },
        /* netmos_9xx5_combo */         { 1, { { 2, -1 }, }, netmos_parallel_init },
-       /* netmos_9855 */               { 1, { { 0, -1 }, }, netmos_parallel_init },
+       /* netmos_9855 */               { 1, { { 2, -1 }, }, netmos_parallel_init },
        /* avlab_1s1p     */            { 1, { { 1, 2}, } },
        /* avlab_1s2p     */            { 2, { { 1, 2}, { 3, 4 },} },
        /* avlab_2s1p     */            { 1, { { 2, 3}, } },
@@ -185,7 +187,7 @@ static struct pciserial_board pci_parport_serial_boards[] __devinitdata = {
                .uart_offset    = 8,
        },
        [netmos_9855] = {
-               .flags          = FL_BASE2 | FL_BASE_BARS,
+               .flags          = FL_BASE4 | FL_BASE_BARS,
                .num_ports      = 1,
                .base_baud      = 115200,
                .uart_offset    = 8,
@@ -305,7 +307,7 @@ static int __devinit parport_register (struct pci_dev *dev,
                dev_dbg(&dev->dev, "PCI parallel port detected: I/O at "
                        "%#lx(%#lx)\n", io_lo, io_hi);
                port = parport_pc_probe_port (io_lo, io_hi, PARPORT_IRQ_NONE,
-                                             PARPORT_DMA_NONE, dev);
+                                             PARPORT_DMA_NONE, &dev->dev);
                if (port) {
                        priv->port[priv->num_par++] = port;
                        success = 1;
@@ -324,10 +326,9 @@ static int __devinit parport_serial_pci_probe (struct pci_dev *dev,
        struct parport_serial_private *priv;
        int err;
 
-       priv = kmalloc (sizeof *priv, GFP_KERNEL);
+       priv = kzalloc (sizeof *priv, GFP_KERNEL);
        if (!priv)
                return -ENOMEM;
-       memset(priv, 0, sizeof(struct parport_serial_private));
        pci_set_drvdata (dev, priv);
 
        err = pci_enable_device (dev);
@@ -392,6 +393,7 @@ static int parport_serial_pci_suspend(struct pci_dev *dev, pm_message_t state)
 static int parport_serial_pci_resume(struct pci_dev *dev)
 {
        struct parport_serial_private *priv = pci_get_drvdata(dev);
+       int err;
 
        pci_set_power_state(dev, PCI_D0);
        pci_restore_state(dev);
@@ -399,7 +401,12 @@ static int parport_serial_pci_resume(struct pci_dev *dev)
        /*
         * The device may have been disabled.  Re-enable it.
         */
-       pci_enable_device(dev);
+       err = pci_enable_device(dev);
+       if (err) {
+               printk(KERN_ERR "parport_serial: %s: error enabling "
+                       "device for resume (%d)\n", pci_name(dev), err);
+               return err;
+       }
 
        if (priv->serial)
                pciserial_resume_ports(priv->serial);