From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755787Ab3E0BnZ (ORCPT ); Sun, 26 May 2013 21:43:25 -0400 Received: from intranet.asianux.com ([58.214.24.6]:35519 "EHLO intranet.asianux.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755718Ab3E0BnX (ORCPT ); Sun, 26 May 2013 21:43:23 -0400 X-Spam-Score: -100.8 Message-ID: <51A2BA03.4030006@asianux.com> Date: Mon, 27 May 2013 09:42:27 +0800 From: Chen Gang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Catalin Marinas , Will Deacon , vgupta@synopsys.com, Tony Lindgren , Santosh Shilimkar CC: Andrew Morton , Rusty Russell , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Linux-Arch Subject: Re: [PATCH] arch: arm64: kernel: sprintf(), 'str' needs additional 1 byte for failure processing References: <51A1E3B3.4060901@asianux.com> In-Reply-To: <51A1E3B3.4060901@asianux.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/26/2013 06:28 PM, Chen Gang wrote: > > When failure occurs at the last looping cycle (when 'i == 0'), it will > print "bad PC value" instead of "(%08x) ", which needs additional 1 > byte. > > If not add 1 byte, the str will not be NUL terminated, and the next > printk() will cause issue. > Oh, I type incorrect contents. It should be "If not add 1 byte, it will memory overflow" I will send patch v2. > Signed-off-by: Chen Gang > --- > arch/arm64/kernel/traps.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c > index 61d7dd2..c2f68d2 100644 > --- a/arch/arm64/kernel/traps.c > +++ b/arch/arm64/kernel/traps.c > @@ -100,7 +100,7 @@ static void dump_instr(const char *lvl, struct pt_regs *regs) > { > unsigned long addr = instruction_pointer(regs); > mm_segment_t fs; > - char str[sizeof("00000000 ") * 5 + 2 + 1], *p = str; > + char str[sizeof("00000000 ") * 5 + 2 + 1 + 1], *p = str; > int i; > > /* > -- Chen Gang Asianux Corporation