From patchwork Wed Aug 7 03:45:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 2839771 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1800B9F485 for ; Wed, 7 Aug 2013 04:13:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 18FCA2018B for ; Wed, 7 Aug 2013 04:13:44 +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 10173200E7 for ; Wed, 7 Aug 2013 04:13:43 +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 1V6ujM-0003wy-Cb; Wed, 07 Aug 2013 03:48:14 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V6uiW-0001Qz-VC; Wed, 07 Aug 2013 03:47:20 +0000 Received: from mail-yh0-f51.google.com ([209.85.213.51]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V6uh7-0001Ds-2b for linux-arm-kernel@lists.infradead.org; Wed, 07 Aug 2013 03:46:01 +0000 Received: by mail-yh0-f51.google.com with SMTP id 29so495105yhl.38 for ; Tue, 06 Aug 2013 20:45:31 -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=/aJIiSn/tYUDkMFti7vP+lInRrRczUE9MlgjZtFeXJE=; b=UVw9leT5B5VPCPfNGQXgI+0D5M4tT7zDdmyRu0VcqyCiVJxV6u4Oj8fpoRvNWJqaoN tiI40myAQfUOtYiVi4mjWqyho/ui92UXx629RFKqDrLh5PV3l0S0dYCMMiQJAC073N7K QIlLqxP7nwttoyft94AAcj1ajstv3Dion/oDk/99Da5MoVC8mYFlOObYnH73BXdXdJUd Z7YAy7gdEWJ9EbWQEtsPNw+eyqyQJFn7YqkTvAwIOgc2nDLs5/OZ4LXdvygdDyuCDazz SBvoeMVW4EyKkNIguyJjxlQb13kqNYhaEIST1sbS4wU0p8bGD0NSlDqpqmAUzB/nyetu D+2w== X-Gm-Message-State: ALoCoQmKn2Auxd8cvoZA68H5XEDw81SviYe+fQRn/xLBiSChIs/dE4VZ2Qd2lTt1FAznKnzVW5IZ X-Received: by 10.236.56.227 with SMTP id m63mr656304yhc.233.1375847131776; Tue, 06 Aug 2013 20:45:31 -0700 (PDT) Received: from rfranz-v430.caveonetworks.com (64.2.3.195.ptr.us.xo.net. [64.2.3.195]) by mx.google.com with ESMTPSA id s65sm6814380yhs.14.2013.08.06.20.45.30 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 06 Aug 2013 20:45:31 -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 08/17] Allow efi_free() to be called with size of 0, and do nothing in that case. Date: Tue, 6 Aug 2013 20:45:04 -0700 Message-Id: <1375847113-24884-9-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1375847113-24884-1-git-send-email-roy.franz@linaro.org> References: <1375847113-24884-1-git-send-email-roy.franz@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130806_234553_379084_904DCB6A X-CRM114-Status: GOOD ( 10.81 ) X-Spam-Score: -2.6 (--) Cc: Roy Franz , dave.martin@arm.com, leif.lindholm@linaro.org 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 8582650..bce0473 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); }