From mboxrd@z Thu Jan 1 00:00:00 1970 From: Borislav Petkov Subject: Re: [PATCH v7 04/25] ACPI / APEI: Make hest.c manage the estatus memory pool Date: Wed, 19 Dec 2018 15:42:34 +0100 Message-ID: <20181219144234.GA31643@zn.tnic> References: <20181203180613.228133-1-james.morse@arm.com> <20181203180613.228133-5-james.morse@arm.com> <20181211164802.GI27375@zn.tnic> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu To: James Morse Cc: Rafael Wysocki , Tony Luck , Fan Wu , linux-mm@kvack.org, Marc Zyngier , Catalin Marinas , Will Deacon , Dongjiu Geng , linux-acpi@vger.kernel.org, Naoya Horiguchi , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Len Brown List-Id: linux-acpi@vger.kernel.org On Fri, Dec 14, 2018 at 01:56:16PM +0000, James Morse wrote: > /me digs a bit, > > ghes_estatus_pool_init() allocates memory from hest_ghes_dev_register(). > Its caller is behind a 'if (!ghes_disable)' in acpi_hest_init(), and is after > another 2 calls to apei_hest_parse(). > > If ghes_disable is set, we don't call this thing. > If hest_disable is set, acpi_hest_init() exits early. > If we don't have a HEST table, acpi_hest_init() exits early. > > ... if the HEST table doesn't have any GHES entries, hest_ghes_dev_register() is > called with ghes_count==0, and does nothing useful. (kmalloc_alloc_array(0,...) > great!) But we do call ghes_estatus_pool_init(). > > I think a check that ghes_count is non-zero before calling > hest_ghes_dev_register() is the cleanest way to avoid this. Grrr, what an effing mess that code is! There's hest_disable *and* ghes_disable. Do we really need them both? With my simplifier hat on I wanna say, we should have a single switch - apei_disable - and kill those other two. What a damn mess that is. > I wanted the estatus pool to be initialised before creating the platform devices > in case the order of these things is changed in the future and they get probed > immediately, before the pool is initialised. Hmmm. Actually, I meant flipping those two calls: rc = ghes_estatus_pool_init(ghes_count); if (rc) goto out; rc = apei_hest_parse(hest_parse_ghes, &ghes_arr); if (rc) goto err; to rc = apei_hest_parse(hest_parse_ghes, &ghes_arr); if (rc) goto err; rc = ghes_estatus_pool_init(ghes_count); if (rc) goto out; so as not to alloc the pool unnecessarily if the parsing fails. Also, AFAICT, the order you have them in now might be a problem anyway if apei_hest_parse(hest_parse_ghes, &ghes_arr); fails because then you goto err and and that pool leaks, right? Thx. -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.