Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2fd2bdfc authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman
Browse files

staging: comedi: pcmuio: fix possible NULL deref on detach



pcmuio_detach() is called by the comedi core even if pcmuio_attach()
returned an error, so `dev->private` might be `NULL`.  Check for that
before dereferencing it.

Also, as pointed out by Dan Carpenter, there is no need to check the
pointer passed to `kfree()` is non-NULL, so remove that check.

Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b88e75bb
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -672,12 +672,13 @@ static void pcmuio_detach(struct comedi_device *dev)
	struct pcmuio_private *devpriv = dev->private;
	int i;

	if (devpriv) {
		for (i = 0; i < PCMUIO_MAX_ASICS; ++i) {
			if (devpriv->asics[i].irq)
				free_irq(devpriv->asics[i].irq, dev);
		}
	if (devpriv && devpriv->sprivs)
		kfree(devpriv->sprivs);
	}
	comedi_legacy_detach(dev);
}