lkml.org 
[lkml]   [2015]   [Oct]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/3] staging: android: ion: Add ion driver for Hi6220 SoC platform
From
Date


On 2015/10/9 16:58, Dan Carpenter wrote:
> On Fri, Oct 09, 2015 at 11:53:32AM +0300, Dan Carpenter wrote:
>>> +out:
>>
>> Labels named "out" are bug prone because handling everything is harder
>> than using named labels and unwinding one step at a time. The bug here
>> is that we don't call ion_device_destroy().
>>
>>> + for (i = 0; i < num_heaps; ++i)
>>> + ion_heap_destroy(heaps[i]);
>>> + return err;
>>
>> Write it like this:
>>
>> err_free_heaps:
>> for (i = 0; i < num_heaps; ++i)
>> ion_heap_destroy(heaps[i]);
>> err_free_idev:
>> ion_device_destroy(idev);
>>
>> return err;
>>
>>> +}
>>> +
>>> +static int hi6220_ion_remove(struct platform_device *pdev)
>>> +{
>>> + int i;
>>> +
>>> + ion_device_destroy(idev);
>>> + for (i = 0; i < num_heaps; i++) {
>>> + if (!heaps[i])
>>> + continue;
>>
>> We don't really need this NULL check and it isn't there in the
>> hi6220_ion_probe() unwind code.
>>
>>> + ion_heap_destroy(heaps[i]);
>>> + heaps[i] = NULL;
>>> + }
>>> +
>
> Really the unwind from probe() and the remove() function should have
> similar code. For example, is it important to set heaps[i] to NULL?
> If so then we should do it in the probe function as well. If not then
> we could leave it out of the remove function.
>
> Also the ion_device_destroy(idev) should be after freeing heaps in the
> remove function.
>
Thanks.
I will modify this next version.

> regards,
> dan carpenter
>
>
> .
>



\
 
 \ /
  Last update: 2015-10-10 08:41    [W:0.076 / U:0.376 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site