From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753480AbbE0RHl (ORCPT ); Wed, 27 May 2015 13:07:41 -0400 Received: from smtprelay0038.hostedemail.com ([216.40.44.38]:49290 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751287AbbE0RHj (ORCPT ); Wed, 27 May 2015 13:07:39 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::::::::::::,RULES_HIT:41:305:355:379:541:599:960:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2194:2199:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3867:3868:3871:3872:3874:4250:4321:5007:6142:6143:6261:6737:7904:10004:10400:10848:11026:11657:11658:11914:12043:12048:12517:12519:12679:12740:13069:13138:13161:13229:13231:13311:13357:21080:21088,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: coat73_4248b5753f021 X-Filterd-Recvd-Size: 2474 Message-ID: <1432746454.2846.154.camel@perches.com> Subject: Re: [tip:x86/cpu] x86/cpu: Strip any /proc/ cpuinfo model name field whitespace From: Joe Perches To: luto@amacapital.net, bp@alien8.de, peterz@infradead.org, dvlasenk@redhat.com, torvalds@linux-foundation.org, imammedo@redhat.com, brgerst@gmail.com, mingo@kernel.org, prarit@redhat.com, dave.hansen@linux.intel.com, fenghua.yu@intel.com, hpa@zytor.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, bp@suse.de Cc: linux-tip-commits@vger.kernel.org Date: Wed, 27 May 2015 10:07:34 -0700 In-Reply-To: References: <1432050210-32036-1-git-send-email-prarit@redhat.com> <1432628901-18044-15-git-send-email-bp@alien8.de> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.11-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2015-05-27 at 07:16 -0700, tip-bot for Prarit Bhargava wrote: > x86/cpu: Strip any /proc/cpuinfo model name field whitespace [] > diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c > @@ -431,18 +430,10 @@ static void get_model_name(struct cpuinfo_x86 *c) > c->x86_model_id[48] = 0; > > /* > - * Intel chips right-justify this string for some dumb reason; > - * undo that brain damage: > + * Remove leading whitespace on Intel processors and trailing > + * whitespace on AMD processors. > */ > - p = q = &c->x86_model_id[0]; > - while (*p == ' ') > - p++; > - if (p != q) { > - while (*p) > - *q++ = *p++; > - while (q <= &c->x86_model_id[48]) > - *q++ = '\0'; /* Zero-pad the rest */ > - } > + memmove(c->x86_model_id, strim(c->x86_model_id), 48); This code can memmove from beyond the x86_model_id field. If the id was a single right justified char, to avoid overrunning the field, it'd be safer moving only the actual string and terminating 0 though this code is sub-optimal: memmove(c->x86_model_id, strim(c->x86_model_id), strlen(strim(c->x86_model_id) + 1); Maybe: char *model = strim(c->x86_model_id); memmove(c->x86_model_id, model, strlen(model) + 1);