Skip to contentSkip to conversation

staging/comedi/drivers: free allocated priv and release resources if comedi_alloc_subdevices

PATCH In review Devendra Naga 2 participants 3 messages Jul 1, 2012 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 staging/comedi/drivers: free allocated priv and release resources if comedi_alloc_subdevices

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.

---
 drivers/staging/comedi/drivers/fl512.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/staging/comedi/drivers/fl512.c +4 -1
index 52e6d14..6538497 100644
@@ -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);
+		release_region(iobase, FL512_SIZE);
 		return ret;
+	}
 
 	/*
 	 * this if the definitions of the supdevices, 2 have been defined
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 7 lines · 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.

---

Please drop this. Devendra sent a v2 of this.

Devendra, please reply to the thread when you want a patch to be dropped. Don't make other people (me) clean up for you.

regards,
dan carpenter

#2 lore raw

Hi Dan,

Quoted 6 lines · Dan Carpenter
Quoted 5 lines · 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.

Quoted 8 lines
Quoted 2 lines

---

Please drop this. Devendra sent a v2 of this.

Devendra, please reply to the thread when you want a patch to be dropped. Don't make other people (me) clean up for you.

sorry about that, i will say from now.

Quoted 3 lines

regards,
dan carpenter

Thanks,