Skip to content

Commit

Permalink
staging: comedi: ni_670x: fix dereference of an invalid pointer
Browse files Browse the repository at this point in the history
The attach if this driver can fail before the subdevices are
allocated. If the attach fails the comedi core will call the
detach routine to allow the driver to do it's cleanup.

We need to make sure that the subdevice allocation was successful
before trying to dereference subdevice[0] to free the allocated
range table list.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Jul 6, 2012
1 parent 464c945 commit 70fcd1b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/staging/comedi/drivers/ni_670x.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,13 @@ static int ni_670x_attach(struct comedi_device *dev,
static void ni_670x_detach(struct comedi_device *dev)
{
struct ni_670x_private *devpriv = dev->private;
struct comedi_subdevice *s;

kfree(dev->subdevices[0].range_table_list);
if (dev->n_subdevices) {
s = dev->subdevices + 0;
if (s)
kfree(s->range_table_list);
}
if (devpriv && devpriv->mite)
mite_unsetup(devpriv->mite);
if (dev->irq)
Expand Down

0 comments on commit 70fcd1b

Please sign in to comment.