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 > > > . > _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel