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-Tag: firefly_0821_release~176^2~4193^2~870 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c095fad35ec72835540b3a9b1166dcd83a74ade3;p=firefly-linux-kernel-4.4.55.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)];