From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933452AbbLVWwq (ORCPT ); Tue, 22 Dec 2015 17:52:46 -0500 Received: from mga11.intel.com ([192.55.52.93]:12830 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932675AbbLVWwn (ORCPT ); Tue, 22 Dec 2015 17:52:43 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,466,1444719600"; d="scan'208";a="867726227" Subject: [PATCH 4/5] x86: pass in size to early cmdline parsing To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Dave Hansen , dave.hansen@linux.intel.com, bp@suse.de, hpa@zytor.com, fenghua.yu@intel.com, yu-cheng.yu@intel.com From: Dave Hansen Date: Tue, 22 Dec 2015 14:52:43 -0800 References: <20151222225237.08CDE5F1@viggo.jf.intel.com> In-Reply-To: <20151222225237.08CDE5F1@viggo.jf.intel.com> Message-Id: <20151222225243.5CC47EB6@viggo.jf.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Hansen We will use this in a few patches to implement tests for early parsing. Signed-off-by: Dave Hansen Cc: Borislav Petkov Cc: H. Peter Anvin Cc: linux-kernel@vger.kernel.org Cc: fenghua.yu@intel.com Cc: yu-cheng.yu@intel.com --- b/arch/x86/lib/cmdline.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff -puN arch/x86/lib/cmdline.c~pass-in-cmdline-size arch/x86/lib/cmdline.c --- a/arch/x86/lib/cmdline.c~pass-in-cmdline-size 2015-12-22 11:56:59.859204417 -0800 +++ b/arch/x86/lib/cmdline.c 2015-12-22 11:56:59.862204552 -0800 @@ -25,7 +25,8 @@ static inline int myisspace(u8 c) * as an entire word in @cmdline. For instance, if @option="car" * then a cmdline which contains "cart" will not match. */ -int cmdline_find_option_bool(const char *cmdline, const char *option) +static int __cmdline_find_option_bool(const char *cmdline, + int max_cmdline_size, const char *option) { char c; int pos = 0, wstart = 0; @@ -43,7 +44,7 @@ int cmdline_find_option_bool(const char * This 'pos' check ensures we do not overrun * a non-NULL-terminated 'cmdline' */ - while (pos < COMMAND_LINE_SIZE) { + while (pos < max_cmdline_size) { c = *(char *)cmdline++; pos++; @@ -101,3 +102,9 @@ int cmdline_find_option_bool(const char return 0; /* Buffer overrun */ } + +int cmdline_find_option_bool(const char *cmdline, const char *option) +{ + return __cmdline_find_option_bool(cmdline, COMMAND_LINE_SIZE, + option); +} _