From: Kumar Amit Mehta Date: Tue, 25 Feb 2014 23:04:45 +0000 (+0200) Subject: staging: comedi: drivers: fix for a potential NULL pointer dereference X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c095fad35ec72835540b3a9b1166dcd83a74ade3;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git staging: comedi: drivers: fix for a potential NULL pointer dereference Return -ENOMEM in ni_E_init if ni_gpct_device_construct returns NULL Signed-off-by: Kumar Amit Mehta Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 8adb535516bd..3a86d482babd 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -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)];