Re: [PATCH] x86/microcode/intel: Fix allocation size of struct ucode_patch

2017-01-06 Thread Borislav Petkov
On Fri, Jan 06, 2017 at 12:14:13AM +, Junichi Nomura wrote: > Personally I have same opinion as yours. :) > > But according to Documentation/process/coding-style.rst, it seems > "sizeof(*p)" is preferred style and the reason there makes some > sense. > > Quote from coding-style.rst: > > The

Re: [PATCH] x86/microcode/intel: Fix allocation size of struct ucode_patch

2017-01-05 Thread Junichi Nomura
On 01/06/17 09:02, Borislav Petkov wrote: > On Thu, Jan 05, 2017 at 11:52:07PM +, Junichi Nomura wrote: + p = kzalloc(sizeof(struct ucode_patch), GFP_KERNEL); >>> >>> Perhaps sizeof(*p) ? >> >> Yeah, that might be preferred. > > No, those things are never preferred because > >

Re: [PATCH] x86/microcode/intel: Fix allocation size of struct ucode_patch

2017-01-05 Thread Borislav Petkov
On Thu, Jan 05, 2017 at 11:52:07PM +, Junichi Nomura wrote: > >> + p = kzalloc(sizeof(struct ucode_patch), GFP_KERNEL); > > > > Perhaps sizeof(*p) ? > > Yeah, that might be preferred. No, those things are never preferred because sizeof(struct ) tells you exactly the size of w

Re: [PATCH] x86/microcode/intel: Fix allocation size of struct ucode_patch

2017-01-05 Thread Junichi Nomura
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/mi

Re: [PATCH] x86/microcode/intel: Fix allocation size of struct ucode_patch

2017-01-05 Thread Andy Shevchenko
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

Re: [PATCH] x86/microcode/intel: Fix allocation size of struct ucode_patch

2017-01-05 Thread Borislav Petkov
On Thu, Jan 05, 2017 at 01:03:51AM +, 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") > >