Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1243827
| From | chenfeng <puck.chen@hisilicon.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 2/3] staging: android: ion: Add ion driver for Hi6220 SoC platform |
| Date | 2015-10-10 08:20 +0200 |
| Message-ID | <qhVFE-RN-7@gated-at.bofh.it> (permalink) |
| References | <qheAF-6eu-1@gated-at.bofh.it> <qheAH-6eu-21@gated-at.bofh.it> <qhBGW-5Da-25@gated-at.bofh.it> <qhBGX-5Da-29@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
>
>
> .
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 1/3] docs: dts: Add documentation for hi6220 SoC ION node Chen Feng <puck.chen@hisilicon.com> - 2015-10-08 10:20 +0200
[PATCH 2/3] staging: android: ion: Add ion driver for Hi6220 SoC platform Chen Feng <puck.chen@hisilicon.com> - 2015-10-08 10:20 +0200
Re: [PATCH 2/3] staging: android: ion: Add ion driver for Hi6220 SoC platform Greg KH <gregkh@linuxfoundation.org> - 2015-10-08 11:40 +0200
Re: [PATCH 2/3] staging: android: ion: Add ion driver for Hi6220 SoC platform Dan Carpenter <dan.carpenter@oracle.com> - 2015-10-09 11:00 +0200
Re: [PATCH 2/3] staging: android: ion: Add ion driver for Hi6220 SoC platform Dan Carpenter <dan.carpenter@oracle.com> - 2015-10-09 11:00 +0200
Re: [PATCH 2/3] staging: android: ion: Add ion driver for Hi6220 SoC platform chenfeng <puck.chen@hisilicon.com> - 2015-10-10 08:20 +0200
Re: [PATCH 2/3] staging: android: ion: Add ion driver for Hi6220 SoC platform xuyiping <xuyiping@hisilicon.com> - 2015-10-09 11:20 +0200
[PATCH 3/3] arm64: dts: Add dts files to enable ION on Hi6220 SoC. Chen Feng <puck.chen@hisilicon.com> - 2015-10-08 10:20 +0200
csiph-web