Skip to contentSkip to conversation

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

PATCH Superseded Devendra Naga 3 participants 5 messages Jul 1, 2012 – Jul 2, 2012 Staging

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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..ad64b32 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->priv);
+		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 6 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.

This breaks the build.

Also Hartley and Ian, what's the point of alloc_private()? It's just hiding stuff which we need to know about and use later on anyway.

regards,
dan carpenter

#2 lore raw

Hi Dan,

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

This breaks the build.

dev->priv should be dev->private. I was in a hurry to send the fix and didn't build tested,

Quoted 9 lines

Also Hartley and Ian, what's the point of alloc_private()? It's just hiding stuff which we need to know about and use later on anyway.

regards,
dan carpenter

sorry again,

Devendra.

#3 lore raw

Hi,

Dropping the patch 2/2 and its V2 also because of build breakage, sending V3 in a few minutes.

Patch 1/2 is fine though.

Thanks,
Devendra

#4 lore raw
In reply to Dan Carpenter
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 7 lines
Quoted 1 line

This breaks the build.

Also Hartley and Ian, what's the point of alloc_private()? It's just hiding stuff which we need to know about and use later on anyway.

Granted, it was more useful before we got kzalloc()!

Signature · 2 lines
-=( Ian Abbott @ MEV Ltd.    E-mail: <[email protected]>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-