From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linuxppc-dev@lists.ozlabs.org,
Alex Williamson <alex.williamson@redhat.com>,
Alexey Kardashevskiy <aik@ozlabs.ru>,
Andrew Morton <akpm@linux-foundation.org>,
Bart Van Assche <bart.vanassche@sandisk.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
David Gibson <david@gibson.dropbear.id.au>,
Doug Ledford <dledford@redhat.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Johan Hovold <johan@kernel.org>,
Masahiro Yamada <yamada.masahiro@socionext.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Nathan Fontenot <nfont@linux.vnet.ibm.com>,
Paul Mackerras <paulus@samba.org>, Rob Herring <robh@kernel.org>,
Sahil Mehta <sahilmehta17@gmail.com>,
Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 5/5] powerpc-pseries: Less function calls in iommu_pseries_alloc_group() after error detection
Date: Wed, 18 Oct 2017 21:27:57 +0200 [thread overview]
Message-ID: <45cdde43-075d-10c0-ab34-1ce1aa4dfa17@users.sourceforge.net> (raw)
In-Reply-To: <0d221be4-1402-0499-d95e-afa4a30e1f33@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 18 Oct 2017 20:48:52 +0200
The kfree() function was called in up to two cases by the
iommu_pseries_alloc_group() function during error handling
even if the passed variable contained a null pointer.
* Adjust jump targets according to the Linux coding style convention.
* Delete initialisations for the variables "tbl" and "tgl"
which became unnecessary with this refactoring.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
arch/powerpc/platforms/pseries/iommu.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index 207ff8351af1..13b424f34039 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -56,8 +56,8 @@
static struct iommu_table_group *iommu_pseries_alloc_group(int node)
{
struct iommu_table_group *table_group;
- struct iommu_table *tbl = NULL;
- struct iommu_table_group_link *tgl = NULL;
+ struct iommu_table *tbl;
+ struct iommu_table_group_link *tgl;
table_group = kzalloc_node(sizeof(*table_group), GFP_KERNEL, node);
if (!table_group)
@@ -65,11 +65,11 @@ static struct iommu_table_group *iommu_pseries_alloc_group(int node)
tbl = kzalloc_node(sizeof(*tbl), GFP_KERNEL, node);
if (!tbl)
- goto fail_exit;
+ goto free_group;
tgl = kzalloc_node(sizeof(*tgl), GFP_KERNEL, node);
if (!tgl)
- goto fail_exit;
+ goto free_table;
INIT_LIST_HEAD_RCU(&tbl->it_group_list);
kref_init(&tbl->it_kref);
@@ -80,11 +80,10 @@ static struct iommu_table_group *iommu_pseries_alloc_group(int node)
return table_group;
-fail_exit:
- kfree(tgl);
- kfree(table_group);
+free_table:
kfree(tbl);
-
+free_group:
+ kfree(table_group);
return NULL;
}
--
2.14.2
prev parent reply other threads:[~2017-10-18 19:28 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-18 19:20 [PATCH 0/5] PowerPC-pSeries: Adjustments for seven function implementations SF Markus Elfring
2017-10-18 19:21 ` [PATCH 1/5] powerpc-pseries: Delete five error messages for a failed memory allocation SF Markus Elfring
2017-10-18 19:23 ` [PATCH 2/5] powerpc-pseries: Improve nine size determinations SF Markus Elfring
2017-10-18 19:24 ` [PATCH 3/5] powerpc-pseries: Delete an unnecessary variable initialisation in iommu_pseries_alloc_group() SF Markus Elfring
2017-10-19 11:37 ` Michal Suchánek
2017-10-19 11:49 ` SF Markus Elfring
2017-10-19 12:55 ` Dan Carpenter
2017-10-19 13:51 ` Michal Suchánek
2017-10-20 1:06 ` David Gibson
2017-10-18 19:26 ` [PATCH 4/5] powerpc-pseries: Return directly after a failed kzalloc_node() " SF Markus Elfring
2017-10-19 11:41 ` Michal Suchánek
2017-10-19 12:04 ` SF Markus Elfring
2017-10-19 12:39 ` Michal Suchánek
2017-10-24 8:09 ` [4/5] " Michael Ellerman
2017-10-18 19:27 ` SF Markus Elfring [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=45cdde43-075d-10c0-ab34-1ce1aa4dfa17@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=aik@ozlabs.ru \
--cc=akpm@linux-foundation.org \
--cc=alex.williamson@redhat.com \
--cc=bart.vanassche@sandisk.com \
--cc=benh@kernel.crashing.org \
--cc=david@gibson.dropbear.id.au \
--cc=dledford@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=nfont@linux.vnet.ibm.com \
--cc=paulus@samba.org \
--cc=robh@kernel.org \
--cc=sahilmehta17@gmail.com \
--cc=tyreld@linux.vnet.ibm.com \
--cc=yamada.masahiro@socionext.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).