From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753302AbdJSMFO (ORCPT ); Thu, 19 Oct 2017 08:05:14 -0400 Received: from mout.web.de ([212.227.17.11]:53033 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753055AbdJSMFM (ORCPT ); Thu, 19 Oct 2017 08:05:12 -0400 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 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171019134148.52b890b4@kitsune.suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:4i5U25TqH02MTaFtTH7jzPb19kcmDj4T3j5A6eNkxoD2DRMBdER 4G2ABbxFS8Goo9mvHn0k/YpHzH+l6s1EbB0viocyNIklK2APpBScJi8nfozOwgOk/3U8EjD f3akEPfAgJRozLghYzMy70Vi8WkZ+/AVh+LhfBqfaJK6SD2apr6izeBj/EJmDb6Buti3wc0 SkenY8uURV634E/x8AlGA== X-UI-Out-Filterresults: notjunk:1;V01:K0:G7i2IuRc+x4=:mTjR1xJvrlLfgCdtoqarpF BzVOQimkkYWZ4p/NQbbSXjjP852djRaepsjDf+g5ORiAJa0uMGB/xz0nMvlCBsUHn/EkqznmO 6upgAH6UfZ64U+SMaDycGji+lkRS9GSo/Wy6XTjBePG1uttAQTIiQi9W4/ouJiPakgdyN/22o ELDb7ioatjqR09WPTqMuSkXnGsqb45x8Y2CtUDJdnkfykx9Lxvi7682mllKtt1qKONBX482qD ZKEPU8GIW6c2dfgzSG/fBPjGJ4YcKd7BGGkkRlUGmiMiDxSuJqj0n7n92+22ePJXQ8ce/aIHJ GFN0hUoT/P4PaL3PgNfSgyUJGyrOl5aAqQs5D56FNUlPqvf3rgX4J1qfTTTDu0fDGeMIaZarN BCvOvsWOkUYhzJuAwjMnuPvLllB/dC2grY3u9gWySmjcPB/8vDVS7Yo3CFp/12FUTbN+X5oK4 eBWOPm16tNQWYRINod0Xf55wYnALLfR9EFimaDPSIhzFMG1+B6rRQd2VGnbgZMho/vw4ljzYv inVi0XIjTvgzUBINh798HLiiNMjeEZL50g2l9l2YEhtY9Ieuw8NYGK+5MBZOkYyXx9AFrz2xQ 9eLs6V26q4pJRrhw3j/VXfB/bqOtx6HsxjiSQcmcsT6p6KYYlLYOcxPdW1WG5Wu1+ZxMaVxnw YaBRfnoy+GP069p0I1YgBWSZJuViHz6Bsrq14BZfr4az+2/zy566QyfCNFEOeeKW7zmEYlVb6 mDDXPjynz0jS69GzZr1r31NqCYnGB4HKulsUGhwYVYl3T8fzXO0nb61C5Dhug6ghBPv3ugAR3 wdilFtXSXT8U/ZcZIA54CWu/mivKB7B/ETRNPE1pEA32b/JDJk= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >> @@ -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