staging: comedi: drivers: propogate errno from subdev_8255_init()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 3 Feb 2014 17:43:25 +0000 (10:43 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Feb 2014 18:49:19 +0000 (10:49 -0800)
The initialization of the 8255 subdevice can fail due to the allocation
of the private data. Make sure all callers of subdev_8255_init() propogate
the errno.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/adv_pci_dio.c
drivers/staging/comedi/drivers/cb_pcidas64.c
drivers/staging/comedi/drivers/cb_pcimdas.c
drivers/staging/comedi/drivers/das08.c
drivers/staging/comedi/drivers/ni_atmio16d.c
drivers/staging/comedi/drivers/ni_mio_common.c
drivers/staging/comedi/drivers/pcm3724.c

index d4bd61d84dafc0fc14b4d836cf4fd7e6bc8f8647..2d966a87f2e871792afb170e27a1981735231ae5 100644 (file)
@@ -1130,10 +1130,12 @@ static int pci_dio_auto_attach(struct comedi_device *dev,
        for (i = 0; i < MAX_DIO_SUBDEVG; i++)
                for (j = 0; j < this_board->sdio[i].regs; j++) {
                        s = &dev->subdevices[subdev];
-                       subdev_8255_init(dev, s, NULL,
-                                        dev->iobase +
-                                        this_board->sdio[i].addr +
-                                        SIZE_8255 * j);
+                       ret = subdev_8255_init(dev, s, NULL,
+                                              dev->iobase +
+                                              this_board->sdio[i].addr +
+                                              SIZE_8255 * j);
+                       if (ret)
+                               return ret;
                        subdev++;
                }
 
index 4fff1738e3f8c2e45dbd0dfb534344663cd89f48..464c783e566ef3089e69493fb26343706c299b6e 100644 (file)
@@ -3816,16 +3816,19 @@ static int setup_subdevices(struct comedi_device *dev)
        if (thisboard->has_8255) {
                if (thisboard->layout == LAYOUT_4020) {
                        dio_8255_iobase = devpriv->main_iobase + I8255_4020_REG;
-                       subdev_8255_init(dev, s, dio_callback_4020,
-                                        (unsigned long)dio_8255_iobase);
+                       ret = subdev_8255_init(dev, s, dio_callback_4020,
+                                              (unsigned long)dio_8255_iobase);
                } else {
                        dio_8255_iobase =
                                devpriv->dio_counter_iobase + DIO_8255_OFFSET;
-                       subdev_8255_init(dev, s, dio_callback,
-                                        (unsigned long)dio_8255_iobase);
+                       ret = subdev_8255_init(dev, s, dio_callback,
+                                              (unsigned long)dio_8255_iobase);
                }
-       } else
+               if (ret)
+                       return ret;
+       } else {
                s->type = COMEDI_SUBD_UNUSED;
+       }
 
        /*  8 channel dio for 60xx */
        s = &dev->subdevices[5];
index 57295d189ff6a22b101877e307a5dc477c8c5e62..8bf344cd46ded2fd5d5aa5225f9ff48c54b4ed27 100644 (file)
@@ -247,7 +247,9 @@ static int cb_pcimdas_auto_attach(struct comedi_device *dev,
 
        s = &dev->subdevices[2];
        /* digital i/o subdevice */
-       subdev_8255_init(dev, s, NULL, iobase_8255);
+       ret = subdev_8255_init(dev, s, NULL, iobase_8255);
+       if (ret)
+               return ret;
 
        dev_info(dev->class_dev, "%s attached\n", dev->board_name);
 
index e5c0ee9a09c214c9e4d9a4dfb88889f707b989bf..3c0e45837c72853c18279fbfe91bc0bf0ac67d88 100644 (file)
@@ -529,9 +529,10 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
        s = &dev->subdevices[4];
        /* 8255 */
        if (thisboard->i8255_offset != 0) {
-               subdev_8255_init(dev, s, NULL, (unsigned long)(dev->iobase +
-                                                              thisboard->
-                                                              i8255_offset));
+               ret = subdev_8255_init(dev, s, NULL,
+                                      dev->iobase + thisboard->i8255_offset);
+               if (ret)
+                       return ret;
        } else {
                s->type = COMEDI_SUBD_UNUSED;
        }
index e8cd5ddb85c5abba086dc81fa8721df755eeb2b0..4f26aa9424b858055a688c01ae748f12a911d55b 100644 (file)
@@ -723,10 +723,13 @@ static int atmio16d_attach(struct comedi_device *dev,
 
        /* 8255 subdevice */
        s = &dev->subdevices[3];
-       if (board->has_8255)
-               subdev_8255_init(dev, s, NULL, dev->iobase);
-       else
+       if (board->has_8255) {
+               ret = subdev_8255_init(dev, s, NULL, dev->iobase);
+               if (ret)
+                       return ret;
+       } else {
                s->type = COMEDI_SUBD_UNUSED;
+       }
 
 /* don't yet know how to deal with counter/timers */
 #if 0
index 10c27cb278cbb28e49f2d651b19b738e02467a2c..575011533a1891633a02f0a8b11319f27ac3074f 100644 (file)
@@ -4292,10 +4292,14 @@ static int ni_E_init(struct comedi_device *dev)
 
        /* 8255 device */
        s = &dev->subdevices[NI_8255_DIO_SUBDEV];
-       if (board->has_8255)
-               subdev_8255_init(dev, s, ni_8255_callback, (unsigned long)dev);
-       else
+       if (board->has_8255) {
+               ret = subdev_8255_init(dev, s, ni_8255_callback,
+                                      (unsigned long)dev);
+               if (ret)
+                       return ret;
+       } else {
                s->type = COMEDI_SUBD_UNUSED;
+       }
 
        /* formerly general purpose counter/timer device, but no longer used */
        s = &dev->subdevices[NI_UNUSED_SUBDEV];
index f4a49bd649f0e91555813e2d488d76348387ebd1..53e73737a906644e0948f8f8d364341c998c2984 100644 (file)
@@ -225,8 +225,10 @@ static int pcm3724_attach(struct comedi_device *dev,
 
        for (i = 0; i < dev->n_subdevices; i++) {
                s = &dev->subdevices[i];
-               subdev_8255_init(dev, s, subdev_8255_cb,
-                                (unsigned long)(dev->iobase + SIZE_8255 * i));
+               ret = subdev_8255_init(dev, s, subdev_8255_cb,
+                                      dev->iobase + SIZE_8255 * i);
+               if (ret)
+                       return ret;
                s->insn_config = subdev_3724_insn_config;
        }
        return 0;