From patchwork Fri Aug 9 23:26:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 2842255 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E90F6BF546 for ; Fri, 9 Aug 2013 23:29:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2BA1020373 for ; Fri, 9 Aug 2013 23:29:58 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 28B9B20362 for ; Fri, 9 Aug 2013 23:29:57 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V7w6o-0001JG-LF; Fri, 09 Aug 2013 23:28:40 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V7w6I-0003jh-9u; Fri, 09 Aug 2013 23:28:06 +0000 Received: from mail-pb0-f43.google.com ([209.85.160.43]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V7w5E-0003Yt-Ld for linux-arm-kernel@lists.infradead.org; Fri, 09 Aug 2013 23:27:01 +0000 Received: by mail-pb0-f43.google.com with SMTP id md4so4991506pbc.30 for ; Fri, 09 Aug 2013 16:26:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DITyRW3tdrgaglWzhynyBwh3KbJZKStEBdODmBP2q58=; b=DfdF+X+bosRX///H4LRMKBqMsWqQHlvIxHBivgJrTkxb4AGnihZ5swrO4G192AljvL RlK7iT5ULrfl0Vdh6NKc0DoWg4Ah26eDN0cEcWCcqmw7TxCg2OnLEt+BXF+sgnaDXoHF zoZ19+zAMSNu3RFReLqg42SKRnSqeDKstfzS5DXbApFRSPCtJnmDSMlyn60T2yYm52TS b7xuXjD+LOCn6FfvGCMJP1nhgAYmXJcwAaO/b/JKYepJM7LQLh8CP6Xdrp5BJRZscUlE 4OkHxgTZ4fsoGQaY6T70W9UV+iCJY9tnv+20EAIgTF+PRI/+kwfUrJGZ/2SBvQg8oX+i 1acA== X-Gm-Message-State: ALoCoQmtEvpntWz+5WayFBo13ZWJrd7eBjcL7wfrGUjpX25+EqJqkPWhaQS/+nAIHlHPS2tIA1uA X-Received: by 10.68.175.164 with SMTP id cb4mr548067pbc.191.1376090798905; Fri, 09 Aug 2013 16:26:38 -0700 (PDT) Received: from rfranz-i7.local (c-24-10-48-230.hsd1.ca.comcast.net. [24.10.48.230]) by mx.google.com with ESMTPSA id ue9sm24823913pab.7.2013.08.09.16.26.37 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 09 Aug 2013 16:26:38 -0700 (PDT) From: Roy Franz To: linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, matt.fleming@intel.com, linux@arm.linux.org.uk Subject: [PATCH 07/16] Allow efi_free() to be called with size of 0, and do nothing in that case. Date: Fri, 9 Aug 2013 16:26:08 -0700 Message-Id: <1376090777-20090-8-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1376090777-20090-1-git-send-email-roy.franz@linaro.org> References: <1376090777-20090-1-git-send-email-roy.franz@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130809_192700_837268_5C13EAE1 X-CRM114-Status: GOOD ( 11.65 ) X-Spam-Score: -2.6 (--) Cc: Roy Franz , dave.martin@arm.com, leif.lindholm@linaro.org, msalter@redhat.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make efi_free() safely callable with size of 0, similar to free() being callable with NULL pointers. Remove size checks that this makes redundant. This also avoids some size checks in the ARM EFI stub code that will be added as well. Signed-off-by: Roy Franz --- arch/x86/boot/compressed/eboot.c | 3 +-- drivers/firmware/efi/efi-stub-helper.c | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index f44ef2f..bcfdcc2 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -537,8 +537,7 @@ struct boot_params *make_boot_params(void *handle, efi_system_table_t *_table) return boot_params; fail2: - if (options_size) - efi_free(sys_table, options_size, hdr->cmd_line_ptr); + efi_free(sys_table, options_size, hdr->cmd_line_ptr); fail: efi_free(sys_table, 0x4000, (unsigned long)boot_params); return NULL; diff --git a/drivers/firmware/efi/efi-stub-helper.c b/drivers/firmware/efi/efi-stub-helper.c index 647b3ba..c45e287 100644 --- a/drivers/firmware/efi/efi-stub-helper.c +++ b/drivers/firmware/efi/efi-stub-helper.c @@ -253,6 +253,9 @@ static void efi_free(efi_system_table_t *sys_table_arg, unsigned long size, { unsigned long nr_pages; + if (!size) + return; + nr_pages = round_up(size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE; efi_call_phys2(sys_table_arg->boottime->free_pages, addr, nr_pages); }