From 7bf777fbfe7926398063bf669c672e52b28b69d2 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 10 Mar 2016 19:35:54 -0800 Subject: [PATCH] Revert "staging: comedi: drivers: Remove unneeded NULL check before kfree()" This reverts commit 3545bee9b8ec00ba733e17363f494c8761fb5e49. It's not correct. Reported-by: Hartley Sweeten Cc: Janani Ravichandran Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci224.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index 656df1abce89..cac011fdd375 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -1096,8 +1096,10 @@ static void pci224_detach(struct comedi_device *dev) struct pci224_private *devpriv = dev->private; comedi_pci_detach(dev); - kfree(devpriv->ao_scan_vals); - kfree(devpriv->ao_scan_order); + if (devpriv) { + kfree(devpriv->ao_scan_vals); + kfree(devpriv->ao_scan_order); + } } static struct comedi_driver amplc_pci224_driver = { -- 2.39.5