All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V3 2/2] staging/comedi/drivers: free allocated priv and release resources if comedi_alloc_subdevices
@ 2012-07-01 16:20 Devendra Naga
  2012-07-02  8:45 ` Ian Abbott
  0 siblings, 1 reply; 4+ messages in thread
From: Devendra Naga @ 2012-07-01 16:20 UTC (permalink / raw)
  To: Ian Abbott, Mori Hess, Dan Carpenter, Greg Kroah-Hartman,
	H Hartley Sweeten, devel, linux-kernel
  Cc: Devendra Naga

as comedi_alloc_subdevices may fail, we leak out the memory allocated by alloc_private,
and also the I/O regions we requested.

free out the private data pointer of the driver, and release the I/O regions

Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
---
 drivers/staging/comedi/drivers/fl512.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/fl512.c b/drivers/staging/comedi/drivers/fl512.c
index 52e6d14..1c372d1 100644
--- a/drivers/staging/comedi/drivers/fl512.c
+++ b/drivers/staging/comedi/drivers/fl512.c
@@ -135,8 +135,11 @@ static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 #endif
 
 	ret = comedi_alloc_subdevices(dev, 2);
-	if (ret)
+	if (ret) {
+		kfree(dev->private);
+		release_region(iobase, FL512_SIZE);
 		return ret;
+	}
 
 	/*
 	 * this if the definitions of the supdevices, 2 have been defined
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-07-02  9:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-01 16:20 [PATCH V3 2/2] staging/comedi/drivers: free allocated priv and release resources if comedi_alloc_subdevices Devendra Naga
2012-07-02  8:45 ` Ian Abbott
2012-07-02  8:51   ` devendra.aaru
     [not found]     ` <4FF16773.3030202@mev.co.uk>
2012-07-02  9:22       ` devendra.aaru

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.