From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752701AbdJSMjz convert rfc822-to-8bit (ORCPT ); Thu, 19 Oct 2017 08:39:55 -0400 Received: from mx2.suse.de ([195.135.220.15]:59549 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752424AbdJSMjy (ORCPT ); Thu, 19 Oct 2017 08:39:54 -0400 Date: Thu, 19 Oct 2017 14:39:49 +0200 From: Michal =?UTF-8?B?U3VjaMOhbmVr?= To: SF Markus Elfring Cc: linuxppc-dev@lists.ozlabs.org, Rob Herring , Sahil Mehta , Alexey Kardashevskiy , Tyrel Datwyler , kernel-janitors@vger.kernel.org, Doug Ledford , Johan Hovold , Masahiro Yamada , Alex Williamson , Paul Mackerras , Greg Kroah-Hartman , Bart Van Assche , Andrew Morton , Nathan Fontenot , LKML , David Gibson Subject: Re: [PATCH 4/5] powerpc-pseries: Return directly after a failed kzalloc_node() in iommu_pseries_alloc_group() Message-ID: <20171019143949.2c87ea66@kitsune.suse.cz> In-Reply-To: <2f1e61bd-9d79-1b9f-e686-f9d13a6f0afc@users.sourceforge.net> References: <0d221be4-1402-0499-d95e-afa4a30e1f33@users.sourceforge.net> <20171019134148.52b890b4@kitsune.suse.cz> <2f1e61bd-9d79-1b9f-e686-f9d13a6f0afc@users.sourceforge.net> X-Mailer: Claws Mail 3.15.1-dirty (GTK+ 2.24.31; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 19 Oct 2017 14:04:43 +0200 SF Markus Elfring wrote: > >> @@ -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. > …” 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