From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162152AbdAEXyL (ORCPT ); Thu, 5 Jan 2017 18:54:11 -0500 Received: from TYO202.gate.nec.co.jp ([210.143.35.52]:35450 "EHLO tyo202.gate.nec.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1034611AbdAEXxy (ORCPT ); Thu, 5 Jan 2017 18:53:54 -0500 From: Junichi Nomura To: Andy Shevchenko CC: "bp@alien8.de" , "x86@kernel.org" , "linux-kernel@vger.kernel.org" , "tglx@linutronix.de" , "mingo@redhat.com" , "hpa@zytor.com" Subject: Re: [PATCH] x86/microcode/intel: Fix allocation size of struct ucode_patch Thread-Topic: [PATCH] x86/microcode/intel: Fix allocation size of struct ucode_patch Thread-Index: AQHSZu+U/l1IZb2FmEOpgrKPMNh7baEpkfGAgABmwYA= Date: Thu, 5 Jan 2017 23:52:07 +0000 Message-ID: <06089643-a36b-93b2-1d26-0336c4d0583c@ce.jp.nec.com> References: <7a730dc9-ac17-35c4-fe76-dfc94e5ecd95@ce.jp.nec.com> In-Reply-To: Accept-Language: en-US, ja-JP Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.34.125.85] Content-Type: text/plain; charset="utf-8" Content-ID: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id v05NsF6r028931 On 01/06/17 02:44, Andy Shevchenko wrote: > On Thu, Jan 5, 2017 at 3:03 AM, Junichi Nomura wrote: >> We allocate struct ucode_patch here. >> >> "size" is a size of microcode data and used for kmemdup() later >> in this function. >> >> Signed-off-by: Jun'ichi Nomura >> Fixes: 06b8534cb728 ("x86/microcode: Rework microcode loading") >> >> diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c >> index aee3cb5..042f329 100644 >> --- a/arch/x86/kernel/cpu/microcode/intel.c >> +++ b/arch/x86/kernel/cpu/microcode/intel.c >> @@ -150,7 +150,7 @@ static struct ucode_patch *__alloc_microcode_buf(void *data, unsigned int size) >> { >> struct ucode_patch *p; >> >> - p = kzalloc(size, GFP_KERNEL); >> + p = kzalloc(sizeof(struct ucode_patch), GFP_KERNEL); > > Perhaps sizeof(*p) ? Yeah, that might be preferred. >> if (!p) >> return ERR_PTR(-ENOMEM); -- Jun'ichi Nomura, NEC Corporation / NEC Solution Innovators, Ltd.