From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755437AbcKBN4K (ORCPT ); Wed, 2 Nov 2016 09:56:10 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:34091 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751573AbcKBN4I (ORCPT ); Wed, 2 Nov 2016 09:56:08 -0400 Date: Wed, 2 Nov 2016 16:56:03 +0300 From: Eugene Korenevsky To: Ard Biesheuvel Cc: "linux-kernel@vger.kernel.org" , "linux-efi@vger.kernel.org" , Matt Fleming , Linn Crosetto , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar Subject: Re: [PATCH v2] EFI loader: remove redundant code Message-ID: <20161102135603.GA8090@vnote> References: <20161102041855.GA4479@vnote> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > *e820ext is always NULL in 'alloc_e820ext()' (see the code of 'exit_boot()'). > > Without loss of generality we can replace freeing with returning > > EFI_INVALID_PARAMETER. So if the caller would ever incorrectly pass non-NULL > > *e820ext, he will obtain a returned error code. > > > > What exactly are you trying to fix here? Adding new artificial failure > modes is hardly worth it when all you are doing is cleaning up code > that by itself is correct to begin with, but is simply never called. This code (free_pool, assignments) is dead whether it is correct or not. So it is to be removed. The check gives some assurance that memory is not leaked if the calling code is changed. > > @@ -956,11 +956,8 @@ static efi_status_t alloc_e820ext(u32 nr_desc, struct setup_data **e820ext, > > size = sizeof(struct setup_data) + > > sizeof(struct e820entry) * nr_desc; > > > > - if (*e820ext) { > > - efi_call_early(free_pool, *e820ext); > > - *e820ext = NULL; > > - *e820ext_size = 0; > > - } > > + if (*e820ext) > > + return EFI_INVALID_PARAMETER; > > > > status = efi_call_early(allocate_pool, EFI_LOADER_DATA, > > size, (void **)e820ext); > > -- -- Eugene