From 235cd3bde72ab7f798414da1ca675ee2327184ca Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Mon, 2 Jul 2012 10:03:40 +0100 Subject: [PATCH] ni_670x: Fix possible invalid pointer dereference in ni_670x_detach() In ni_670x_detach(), dev->subdevices will be NULL if the call to alloc_subdevices() failed in ni_670x_attach(), so don't dereference it until the pointer has been checked. Spotted by H Hartley Sweeten in the "staging" sources, but used a different check due to difference in behavior of alloc_subdevices() on error between the two versions. Signed-off-by: Ian Abbott --- comedi/drivers/ni_670x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/comedi/drivers/ni_670x.c b/comedi/drivers/ni_670x.c index 65d22bd6..153856e6 100644 --- a/comedi/drivers/ni_670x.c +++ b/comedi/drivers/ni_670x.c @@ -206,7 +206,7 @@ static int ni_670x_detach(comedi_device * dev) { printk("comedi%d: ni_670x: remove\n", dev->minor); - if (dev->subdevices[0].range_table_list) { + if (dev->subdevices && dev->subdevices[0].range_table_list) { kfree(dev->subdevices[0].range_table_list); } if (dev->private && devpriv->mite) -- 2.26.2