On 05/05/2010 05:44 PM, Andy Pugh wrote:
> On 5 May 2010 16:26, Sebastian Kuzminsky<[email protected]>  wrote:
>    
>>>> hm2_tp_pwmgen_parse_md() leaks memory in the error paths.
>>>>          
> I have
>      hm2->tp_pwmgen.instance = (hm2_tp_pwmgen_instance_t
> *)hal_malloc(hm2->tp_pwmgen.num_instances *
> sizeof(hm2_tp_pwmgen_instance_t));
>
> But if I fail out somewhere later, there is no hal_free to tidy up.
> Does kfree work in hal shared memory? That is what I had but it seems
> like it might not be right.
>    

You can't kfree() things you get from hal_malloc(), and there is no 
hal_free(), instead HAL automagically frees all your memory when you 
unload the driver.  And so the feedback I gave you is wrong, and the 
patch I wrote this morning is wrong.  That's what I get for coding 
before my first cup of coffee i guess...  :-(

Also, the reason the pwmgen per-module hal things were made by 
hal_malloc(), instead of being statically allocated like I erroneously 
suggested, is that *all* pins & params need to be made by hal_malloc().  
Static's no good.

So now i'll go revert my totally bogus commit...  Sorry for the noise.


-- 
Sebastian Kuzminsky


------------------------------------------------------------------------------
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to