Devendra Naga | 1 Jul 2012 18:20
Picon

[PATCH V3 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

Signed-off-by: Devendra Naga <devendra.aaru <at> 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
 <at>  <at>  -135,8 +135,11  <at>  <at>  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
(Continue reading)

Ian Abbott | 2 Jul 2012 10:45
Picon
Favicon
Gravatar

Re: [PATCH V3 2/2] staging/comedi/drivers: free allocated priv and release resources if comedi_alloc_subdevices

On 2012-07-01 17:20, Devendra Naga wrote:
> 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 <at> 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
>  <at>  <at>  -135,8 +135,11  <at>  <at>  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
>

(Continue reading)

devendra.aaru | 2 Jul 2012 10:51
Picon

Re: [PATCH V3 2/2] staging/comedi/drivers: free allocated priv and release resources if comedi_alloc_subdevices

On Mon, Jul 2, 2012 at 2:15 PM, Ian Abbott <abbotti <at> mev.co.uk> wrote:
> On 2012-07-01 17:20, Devendra Naga wrote:
>>
>> 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 <at> 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
>>  <at>  <at>  -135,8 +135,11  <at>  <at>  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;
(Continue reading)

Ian Abbott | 2 Jul 2012 11:18
Picon
Favicon
Gravatar

Re: [PATCH V3 2/2] staging/comedi/drivers: free allocated priv and release resources if comedi_alloc_subdevices

On 2012-07-02 09:51, devendra.aaru wrote:
> anyway i have a question
>
> are you going to remove the alloc_private wapper and use kzalloc?

I'm not averse to the idea, but it's not a high priority.

--

-- 
-=( Ian Abbott  <at>  MEV Ltd.    E-mail: <abbotti <at> mev.co.uk>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
devendra.aaru | 2 Jul 2012 11:22
Picon

Re: [PATCH V3 2/2] staging/comedi/drivers: free allocated priv and release resources if comedi_alloc_subdevices

On Mon, Jul 2, 2012 at 2:48 PM, Ian Abbott <abbotti <at> mev.co.uk> wrote:
> On 2012-07-02 09:51, devendra.aaru wrote:
>>
>> anyway i have a question
>>
>> are you going to remove the alloc_private wapper and use kzalloc?
>
>
> I'm not averse to the idea, but it's not a high priority.
>

Then will i do? and change all drivers?
I dunno about any other guys doing it ...
>
> --
> -=( Ian Abbott  <at>  MEV Ltd.    E-mail: <abbotti <at> mev.co.uk>        )=-
> -=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
>
>

Thanks,
Devendra.
Ian Abbott | 2 Jul 2012 12:27
Picon
Favicon
Gravatar

Re: [PATCH V3 2/2] staging/comedi/drivers: free allocated priv and release resources if comedi_alloc_subdevices

On 2012-07-02 10:22, devendra.aaru wrote:
> On Mon, Jul 2, 2012 at 2:48 PM, Ian Abbott <abbotti <at> mev.co.uk> wrote:
>> On 2012-07-02 09:51, devendra.aaru wrote:
>>>
>>> anyway i have a question
>>>
>>> are you going to remove the alloc_private wapper and use kzalloc?
>>
>> I'm not averse to the idea, but it's not a high priority.
>
> Then will i do? and change all drivers?
> I dunno about any other guys doing it ...

It's pretty likely these patches would clash with Hartley's clean-up 
patches if done at around the same time, so it would be best to check 
with him first.

--

-- 
-=( Ian Abbott  <at>  MEV Ltd.    E-mail: <abbotti <at> mev.co.uk>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
H Hartley Sweeten | 2 Jul 2012 17:59
Favicon

RE: [PATCH V3 2/2] staging/comedi/drivers: free allocated priv and release resources if comedi_alloc_subdevices

On Monday, July 02, 2012 3:27 AM, Ian Abbott wrote:
> On 2012-07-02 10:22, devendra.aaru wrote:
>> On Mon, Jul 2, 2012 at 2:48 PM, Ian Abbott <abbotti <at> mev.co.uk> wrote:
>>> On 2012-07-02 09:51, devendra.aaru wrote:
>>>>
>>>> anyway i have a question
>>>>
>>>> are you going to remove the alloc_private wapper and use kzalloc?
>>>
>>> I'm not averse to the idea, but it's not a high priority.
>>
>> Then will i do? and change all drivers?
>> I dunno about any other guys doing it ...
>
> It's pretty likely these patches would clash with Hartley's clean-up 
> patches if done at around the same time, so it would be best to check 
> with him first.

I have a patch ready to do just this. I'm just waiting for some other patches
to get merged into next before I post it.

Thanks,
Hartley
devendra.aaru | 2 Jul 2012 11:22
Picon

Re: [PATCH V3 2/2] staging/comedi/drivers: free allocated priv and release resources if comedi_alloc_subdevices

On Mon, Jul 2, 2012 at 2:48 PM, Ian Abbott <abbotti <at> mev.co.uk> wrote:
> On 2012-07-02 09:51, devendra.aaru wrote:
>>
>> anyway i have a question
>>
>> are you going to remove the alloc_private wapper and use kzalloc?
>
>
> I'm not averse to the idea, but it's not a high priority.
>

Then will i do? and change all drivers?
I dunno about any other guys doing it ...
>
> --
> -=( Ian Abbott  <at>  MEV Ltd.    E-mail: <abbotti <at> mev.co.uk>        )=-
> -=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
>
>

Thanks,
Devendra.
devendra.aaru | 2 Jul 2012 10:51
Picon

Re: [PATCH V3 2/2] staging/comedi/drivers: free allocated priv and release resources if comedi_alloc_subdevices

On Mon, Jul 2, 2012 at 2:15 PM, Ian Abbott <abbotti <at> mev.co.uk> wrote:
> On 2012-07-01 17:20, Devendra Naga wrote:
>>
>> 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 <at> 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
>>  <at>  <at>  -135,8 +135,11  <at>  <at>  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;
(Continue reading)

Ian Abbott | 2 Jul 2012 10:45
Picon
Favicon
Gravatar

Re: [PATCH V3 2/2] staging/comedi/drivers: free allocated priv and release resources if comedi_alloc_subdevices

On 2012-07-01 17:20, Devendra Naga wrote:
> 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 <at> 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
>  <at>  <at>  -135,8 +135,11  <at>  <at>  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
>

(Continue reading)


Gmane