From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969373AbdAFAC4 (ORCPT ); Thu, 5 Jan 2017 19:02:56 -0500 Received: from mail.skyhub.de ([78.46.96.112]:51331 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968928AbdAFACo (ORCPT ); Thu, 5 Jan 2017 19:02:44 -0500 Date: Fri, 6 Jan 2017 01:02:37 +0100 From: Borislav Petkov To: Junichi Nomura Cc: Andy Shevchenko , "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 Message-ID: <20170106000237.5dybkvr35sbba2yx@pd.tnic> References: <7a730dc9-ac17-35c4-fe76-dfc94e5ecd95@ce.jp.nec.com> <06089643-a36b-93b2-1d26-0336c4d0583c@ce.jp.nec.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <06089643-a36b-93b2-1d26-0336c4d0583c@ce.jp.nec.com> User-Agent: NeoMutt/20161014 (1.7.1) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 05, 2017 at 11:52:07PM +0000, 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 what kind of object you're getting vs sizeof(*p) which tells you you're getting the size of what p points to. Now you have to go look at p and what type it is. In the current case, p is defined not far away from the use site but in a larger function, you most likely need to eyeball up to its type when reading the code. Which makes the whole thing less readable. -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.