Commit 4dd9eab3 authored by Markus Elfring's avatar Markus Elfring Committed by Michael Ellerman

powerpc/pseries: Cleanup error handling in iommu_pseries_alloc_group()

Although kfree(NULL) is legal, it's a bit lazy to rely on that to
implement the error handling. So do it the normal Linux way using
labels for each failure path.
Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
[mpe: Squash a few patches and rewrite change log]
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent c28237f1
...@@ -55,23 +55,23 @@ ...@@ -55,23 +55,23 @@
static struct iommu_table_group *iommu_pseries_alloc_group(int node) static struct iommu_table_group *iommu_pseries_alloc_group(int node)
{ {
struct iommu_table_group *table_group = NULL; struct iommu_table_group *table_group;
struct iommu_table *tbl = NULL; struct iommu_table *tbl;
struct iommu_table_group_link *tgl = NULL; struct iommu_table_group_link *tgl;
table_group = kzalloc_node(sizeof(struct iommu_table_group), GFP_KERNEL, table_group = kzalloc_node(sizeof(struct iommu_table_group), GFP_KERNEL,
node); node);
if (!table_group) if (!table_group)
goto fail_exit; return NULL;
tbl = kzalloc_node(sizeof(struct iommu_table), GFP_KERNEL, node); tbl = kzalloc_node(sizeof(struct iommu_table), GFP_KERNEL, node);
if (!tbl) if (!tbl)
goto fail_exit; goto free_group;
tgl = kzalloc_node(sizeof(struct iommu_table_group_link), GFP_KERNEL, tgl = kzalloc_node(sizeof(struct iommu_table_group_link), GFP_KERNEL,
node); node);
if (!tgl) if (!tgl)
goto fail_exit; goto free_table;
INIT_LIST_HEAD_RCU(&tbl->it_group_list); INIT_LIST_HEAD_RCU(&tbl->it_group_list);
kref_init(&tbl->it_kref); kref_init(&tbl->it_kref);
...@@ -82,11 +82,10 @@ static struct iommu_table_group *iommu_pseries_alloc_group(int node) ...@@ -82,11 +82,10 @@ static struct iommu_table_group *iommu_pseries_alloc_group(int node)
return table_group; return table_group;
fail_exit: free_table:
kfree(tgl);
kfree(table_group);
kfree(tbl); kfree(tbl);
free_group:
kfree(table_group);
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment