staging: comedi: drivers: fix for a potential NULL pointer dereference
authorKumar Amit Mehta <gmate.amit@gmail.com>
Tue, 25 Feb 2014 23:04:45 +0000 (01:04 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Feb 2014 16:38:12 +0000 (08:38 -0800)
Return -ENOMEM in ni_E_init if ni_gpct_device_construct returns NULL

Signed-off-by: Kumar Amit Mehta <gmate.amit@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/ni_mio_common.c

index 8adb535516bdf2216bf82e17f1d9d54457fca2b7..3a86d482babdff13732e3194d6ed259b0962de86 100644 (file)
@@ -4407,6 +4407,9 @@ static int ni_E_init(struct comedi_device *dev)
                                                        &ni_gpct_read_register,
                                                        counter_variant,
                                                        NUM_GPCT);
+       if (!devpriv->counter_dev)
+               return -ENOMEM;
+
        /* General purpose counters */
        for (j = 0; j < NUM_GPCT; ++j) {
                s = &dev->subdevices[NI_GPCT_SUBDEV(j)];