[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1432746454.2846.154.camel@perches.com>
Date: Wed, 27 May 2015 10:07:34 -0700
From: Joe Perches <joe@...ches.com>
To: luto@...capital.net, bp@...en8.de, peterz@...radead.org,
dvlasenk@...hat.com, torvalds@...ux-foundation.org,
imammedo@...hat.com, brgerst@...il.com, mingo@...nel.org,
prarit@...hat.com, dave.hansen@...ux.intel.com,
fenghua.yu@...el.com, hpa@...or.com, linux-kernel@...r.kernel.org,
tglx@...utronix.de, bp@...e.de
Cc: linux-tip-commits@...r.kernel.org
Subject: Re: [tip:x86/cpu] x86/cpu: Strip any /proc/ cpuinfo model name
field whitespace
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);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists