lkml.org 
[lkml]   [2017]   [Oct]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 4/5] powerpc-pseries: Return directly after a failed kzalloc_node() in iommu_pseries_alloc_group()
From
Date
>> @@ -61,7 +61,7 @@ static struct iommu_table_group *iommu_pseries_alloc_group(int node) 
>> table_group = kzalloc_node(sizeof(*table_group), GFP_KERNEL,
>> node); if (!table_group)
>> - goto fail_exit;
>> + return NULL;
>>
>> tbl = kzalloc_node(sizeof(*tbl), GFP_KERNEL, node);
>> if (!tbl)
>
> I have seen quite a few fixes that do inverse of this patch after a
> piece of code allocating some extra piece of memory was added before
> code that just returns on fail because it is the first allocation in
> the function.
>
> This is not useful.

How do you think about an information from the section “7) Centralized exiting
of functions” in the document “coding-style.rst” then?

“…
If there is no cleanup needed then just return directly.
…”


> A final fail_exit that frees everything that could have been allocated
> is much better.

I got an other software development opinion for such use cases.
I prefer only required function calls there.

Regards,
Markus

\
 
 \ /
  Last update: 2017-10-22 17:23    [W:0.396 / U:0.408 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site