Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5612010imm; Mon, 27 Aug 2018 00:41:41 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZzaXjACezTSflamvFRgmmxq4hziYpfuV2FJbDLaTSYny9hKXIOEGQSDi7yhjAtuJXBzqe/ X-Received: by 2002:a62:2e02:: with SMTP id u2-v6mr13282747pfu.134.1535355701259; Mon, 27 Aug 2018 00:41:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535355701; cv=none; d=google.com; s=arc-20160816; b=Y28yT9c9IYwf44dGZXFh8sW5Kb2JpOn34JegluwFqaLzEyaAp0mvDiOBUl/0ipw/E9 qeAq7mmVyU/DXME9W/4ND8djXLHoPN7T3F58KRYX1uZjoFhDscWtoCqTZnAlh858YPUH KM7DbMA960b+XsvCxeut2LfWlfDprAHAinunSCTq2M9tUki9EZICNUYQlZ1RC27JZCMv sg6fKl8kLlIsyNCMglRkxr3qqbJj4dzBwmxmd2OtKxOorPxvYeAhaOJSA92QdZaGYrPK rCOcKHvSCArZtKQQUw3uP8oSNlsx/+2ZjupoSFbYT9ZRihWnt+1BRMEudkwEtjGFY3PI 1kYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=FV3Gd25UUpjbOU2Et2TcKMHpr7RKmmbyvVTGHgyU1Dw=; b=s8rTeHsTbSDu5G4LN0uqq7mY4Zy98jNbm9NzmORu6iwR+sCUpQWRCC2HrxTID7ASx8 XTb/NmLbgOT0dSLNYd75ZTzqfaEpSHi5FTuviI+32m0eVNdthFxlm8WN7D9fP7Fn2iht Kml+TggtWPPKX5kieK4sBKmbYBcfYVT7wzAFn16MOkpYCc25UTHGR98JH8JJRHN9u2+d ViGxznRELEXrcT8fbwqMSAyM94mGI/B8M3dJ6ZRAMzidmB5322bJ63+6sH2yJ/8zcF1H gcFxAzA7Cx10tsLKTUdCbAhkQ34JyOoPQJCxbei2v7Z854/Y5B9rAtrknyJRqMDVaI59 aFEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g31-v6si14009250pld.158.2018.08.27.00.41.25; Mon, 27 Aug 2018 00:41:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727203AbeH0LZP (ORCPT + 99 others); Mon, 27 Aug 2018 07:25:15 -0400 Received: from mail.bootlin.com ([62.4.15.54]:58813 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726978AbeH0LZP (ORCPT ); Mon, 27 Aug 2018 07:25:15 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 7534B20797; Mon, 27 Aug 2018 09:39:47 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (AAubervilliers-681-1-53-19.w90-88.abo.wanadoo.fr [90.88.170.19]) by mail.bootlin.com (Postfix) with ESMTPSA id 1C4FF20789; Mon, 27 Aug 2018 09:39:37 +0200 (CEST) Date: Mon, 27 Aug 2018 09:39:35 +0200 From: Boris Brezillon To: "Gustavo A. R. Silva" Cc: Josh Wu , Miquel Raynal , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Nicolas Ferre , Alexandre Belloni , linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Kees Cook Subject: Re: [PATCH] mtd: rawnand: atmel: use struct_size() in devm_kzalloc() Message-ID: <20180827093935.0234da6e@bbrezillon> In-Reply-To: <20180824010938.GA25581@embeddedor.com> References: <20180824010938.GA25581@embeddedor.com> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Gustavo, On Thu, 23 Aug 2018 20:09:38 -0500 "Gustavo A. R. Silva" wrote: > One of the more common cases of allocation size calculations is finding > the size of a structure that has a zero-sized array at the end, along > with memory for some number of elements for that array. For example: > > struct foo { > int stuff; > void *entry[]; > }; > > instance = devm_kzalloc(dev, sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL); > > Instead of leaving these open-coded and prone to type mistakes, we can > now use the new struct_size() helper: > > instance = devm_kzalloc(dev, struct_size(instance, entry, count), GFP_KERNEL); > > This issue was detected with the help of Coccinelle. > > Signed-off-by: Gustavo A. R. Silva Can we have all NAND controller drivers patched in a single patch instead of having one patch per-driver? Thanks, Boris