From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.web.de (mout.web.de [212.227.17.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3yHngR23XlzDqXx for ; Thu, 19 Oct 2017 23:05:22 +1100 (AEDT) Subject: Re: [PATCH 4/5] powerpc-pseries: Return directly after a failed kzalloc_node() in iommu_pseries_alloc_group() To: =?UTF-8?Q?Michal_Such=c3=a1nek?= , linuxppc-dev@lists.ozlabs.org Cc: Alex Williamson , Alexey Kardashevskiy , Andrew Morton , Bart Van Assche , Benjamin Herrenschmidt , David Gibson , Doug Ledford , Greg Kroah-Hartman , Johan Hovold , Masahiro Yamada , Michael Ellerman , Nathan Fontenot , Paul Mackerras , Rob Herring , Sahil Mehta , Tyrel Datwyler , kernel-janitors@vger.kernel.org, LKML References: <0d221be4-1402-0499-d95e-afa4a30e1f33@users.sourceforge.net> <20171019134148.52b890b4@kitsune.suse.cz> From: SF Markus Elfring Message-ID: <2f1e61bd-9d79-1b9f-e686-f9d13a6f0afc@users.sourceforge.net> Date: Thu, 19 Oct 2017 14:04:43 +0200 MIME-Version: 1.0 In-Reply-To: <20171019134148.52b890b4@kitsune.suse.cz> Content-Type: text/plain; charset=utf-8 List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , >> @@ -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