public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: "Michal Suchánek" <msuchanek@suse•de>
To: SF Markus Elfring <elfring@users•sourceforge.net>
Cc: linuxppc-dev@lists•ozlabs.org, Rob Herring <robh@kernel•org>,
	Sahil Mehta <sahilmehta17@gmail•com>,
	Alexey Kardashevskiy <aik@ozlabs•ru>,
	Tyrel Datwyler <tyreld@linux•vnet.ibm.com>,
	kernel-janitors@vger•kernel.org,
	Doug Ledford <dledford@redhat•com>,
	Johan Hovold <johan@kernel•org>,
	Masahiro Yamada <yamada.masahiro@socionext•com>,
	Alex Williamson <alex.williamson@redhat•com>,
	Paul Mackerras <paulus@samba•org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation•org>,
	Bart Van Assche <bart.vanassche@sandisk•com>,
	Andrew Morton <akpm@linux-foundation•org>,
	Nathan Fontenot <nfont@linux•vnet.ibm.com>,
	LKML <linux-kernel@vger•kernel.org>,
	David Gibson <david@gibson•dropbear.id.au>
Subject: Re: [PATCH 4/5] powerpc-pseries: Return directly after a failed kzalloc_node() in iommu_pseries_alloc_group()
Date: Thu, 19 Oct 2017 14:39:49 +0200	[thread overview]
Message-ID: <20171019143949.2c87ea66@kitsune.suse.cz> (raw)
In-Reply-To: <2f1e61bd-9d79-1b9f-e686-f9d13a6f0afc@users.sourceforge.net>

On Thu, 19 Oct 2017 14:04:43 +0200
SF Markus Elfring <elfring@users•sourceforge.net> wrote:

> >> @@ -61,7 +61,7 @@ static struct iommu_table_group
> >> *iommu_pseries_alloc_group(int node) table_group =3D
> >> kzalloc_node(sizeof(*table_group), GFP_KERNEL, node); if
> >> (!table_group)
> >> -		goto fail_exit;
> >> +		return NULL;
> >> =20
> >>  	tbl =3D kzalloc_node(sizeof(*tbl), GFP_KERNEL, node);
> >>  	if (!tbl) =20
> >=20
> > 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.
> >=20
> > This is not useful. =20
>=20
> How do you think about an information from the section =E2=80=9C7)
> Centralized exiting of functions=E2=80=9D in the document =E2=80=9Ccoding=
-style.rst=E2=80=9D
> then?
>=20
> =E2=80=9C=E2=80=A6
> If there is no cleanup needed then just return directly.
> =E2=80=A6=E2=80=9D

There is also stated benefit

"
- errors by not updating individual exit points when making
  modifications are prevented
"

which is furthered by using the common cleanup even in case no cleanup
is required but running the cleanup does not cause any harm.

Thanks

Michal

  reply	other threads:[~2017-10-19 12:39 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 [this message]
2017-10-24  8:09   ` [4/5] " Michael Ellerman
2017-10-18 19:27 ` [PATCH 5/5] powerpc-pseries: Less function calls in iommu_pseries_alloc_group() after error detection SF Markus Elfring

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=20171019143949.2c87ea66@kitsune.suse.cz \
    --to=msuchanek@suse$(echo .)de \
    --cc=aik@ozlabs$(echo .)ru \
    --cc=akpm@linux-foundation$(echo .)org \
    --cc=alex.williamson@redhat$(echo .)com \
    --cc=bart.vanassche@sandisk$(echo .)com \
    --cc=david@gibson$(echo .)dropbear.id.au \
    --cc=dledford@redhat$(echo .)com \
    --cc=elfring@users$(echo .)sourceforge.net \
    --cc=gregkh@linuxfoundation$(echo .)org \
    --cc=johan@kernel$(echo .)org \
    --cc=kernel-janitors@vger$(echo .)kernel.org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linuxppc-dev@lists$(echo .)ozlabs.org \
    --cc=nfont@linux$(echo .)vnet.ibm.com \
    --cc=paulus@samba$(echo .)org \
    --cc=robh@kernel$(echo .)org \
    --cc=sahilmehta17@gmail$(echo .)com \
    --cc=tyreld@linux$(echo .)vnet.ibm.com \
    --cc=yamada.masahiro@socionext$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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