Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965127AbbEMUsy (ORCPT ); Wed, 13 May 2015 16:48:54 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:55323 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754527AbbEMUsw (ORCPT ); Wed, 13 May 2015 16:48:52 -0400 From: Arnd Bergmann To: Brian Norris Cc: linux-mtd@lists.infradead.org, Dmitry Torokhov , Anatol Pomazao , Ray Jui , Corneliu Doban , Jonathan Richardson , Scott Branden , Florian Fainelli , =?utf-8?B?UmFmYcWCIE1pxYJlY2tp?= , bcm-kernel-feedback-list@broadcom.com, Dan Ehrenberg , Gregory Fong , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Kevin Cernekee Subject: Re: [PATCH v4 08/11] mtd: brcmnand: add BCM63138 support Date: Wed, 13 May 2015 22:48:19 +0200 Message-ID: <2173063.OarFjbCqhk@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <20150513202415.GI11598@ld-irv-0074> References: <1431478424-29230-1-git-send-email-computersforpeace@gmail.com> <5685584.0QXUdSHDpG@wuerfel> <20150513202415.GI11598@ld-irv-0074> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:6pRTh+MMuoQ7t5QeT/hqnSz83J+q2yVPHK7jovY8bJ+KuyYlUtY CRBWYraHUi4GVyWTeKs+lH1+hsIuE6ZKcQ2tEcRUvu1lgi/9QtOHFrKhJCpb814CAtX3dZY 61LqynSKCcukfABIDrCtEpzYCOPMShyhy0QmMXHGmgePm7w9mWbt/ieiyR2/wWpcWSSR1vf gChruapLpTHTh9JADXlGQ== X-UI-Out-Filterresults: notjunk:1; Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1423 Lines: 38 On Wednesday 13 May 2015 13:24:15 Brian Norris wrote: > > > > > > static int bcm63138_nand_probe(...) > > > { > > > struct bcm63138_nand_soc *priv; > > > > > > priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); > > > ... > > > return brcmnand_probe(pdev, &priv->soc); > > > } > > > > That would make struct brcmnand_soc an empty structure, right? > > No, it still contains the function pointers for our callbacks, which is > the entire point. I guess it's more of a 'nand_soc_ops' structure than a > 'nand_soc' pointer now though. > Ah, I see. This is fine for a small number of function pointers, but if you ever get a structure like this with a lot of pointers, it's better to keep them separate, so you can define the structure of function pointers as 'static const' in the client driver, as we do for a number of other operations. The main advantage of that is that you don't have to assign the members manually at run-time, but also putting them into the read-only segment makes it harder for an attacker to overwrite a known function pointer with a pointer to an exploit (assuming they have limited control over writing to kernel memory). Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/