From: Ian Abbott Date: Tue, 20 Aug 2013 15:55:41 +0000 (+0100) Subject: staging: comedi: pcmmio: remove unneeded checks on detach X-Git-Tag: firefly_0821_release~176^2~5471^2~187 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b88e75bb6576d99e0ba4f6edc978293d1ff9c01b;p=firefly-linux-kernel-4.4.55.git staging: comedi: pcmmio: remove unneeded checks on detach As pointed out by Dan carpenter for the similar pcmuio driver, there is no need to check the pointer passed to `kfree()`, so remove that check from `pcmmio_detach()`. Also, check the `devpriv` (`dev->private`) pointer once, outside the `for` loop. Signed-off-by: Ian Abbott Cc: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index aa3c0307483d..574443df42da 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -1156,12 +1156,13 @@ static void pcmmio_detach(struct comedi_device *dev) struct pcmmio_private *devpriv = dev->private; int i; - for (i = 0; i < MAX_ASICS; ++i) { - if (devpriv && devpriv->asics[i].irq) - free_irq(devpriv->asics[i].irq, dev); - } - if (devpriv && devpriv->sprivs) + if (devpriv) { + for (i = 0; i < MAX_ASICS; ++i) { + if (devpriv->asics[i].irq) + free_irq(devpriv->asics[i].irq, dev); + } kfree(devpriv->sprivs); + } comedi_legacy_detach(dev); }