staging/comedi/drivers: free allocated priv and release resources if comedi_alloc_subdevices
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
@@ -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
Quoted 6 lines · Devendra Naga
as
comedi_alloc_subdevicesmay fail, we leak out the memory allocated byalloc_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 <[email protected]>
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
Hi Dan,
Quoted 9 lines · Dan Carpenter
Quoted 6 lines · Devendra Naga
as
comedi_alloc_subdevicesmay fail, we leak out the memory allocated byalloc_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 <[email protected]>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.
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
Quoted 6 lines · Dan Carpenter
Quoted 5 lines · Devendra Naga
as
comedi_alloc_subdevicesmay fail, we leak out the memory allocated byalloc_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
Signed-off-by Devendra Naga <[email protected]>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 )=-