Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3067669imm; Tue, 4 Sep 2018 15:00:13 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaI0g9+WPe3IxVLbC3+dOdZXaMBtSeyjP/Sm1iSxEkiNoKQ4UKJNjYhcaAWt2y06YlyQDoP X-Received: by 2002:a63:6a06:: with SMTP id f6-v6mr21814756pgc.63.1536098412996; Tue, 04 Sep 2018 15:00:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536098412; cv=none; d=google.com; s=arc-20160816; b=hMhZELbJFhJhbILMvs0mWRG1hon3eQgFmgNGcSk+RyqYMhYoigFTmwomuY/FWYcN7W 2HbJBrcTmAqSKHnbAWYaaWZxp9YejDtsu+BvhEN3+IuzPV5VCAuiryWxeSHdg0GXBNrY +jDP/GQZGnN0fkEP0axNAVfI5TmrBKyjyk6mxkkLFiXFSXbPtwVWk/64iMNAdSKPqNfl 6q95r7Q/qzuwffyU0JbFcNcKlfCiPaxaus/2H5trlLUwP4UuGYZSe9OMIS5/MmZlQ7nL 1GG1XTGnxqlARl/9nh7n9zuvIqqzvDCoYzluQqbZI+WUO0T9aSW8CWtvt6193jwnOohA N9fQ== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=58SWcMFLJAbCmFclA16OTFBjrxQFMN7RJ+6O7DT6ni0=; b=CfRdoLwZy0gBwcmpfbfF1ZrIIqrUmh+uAqRCXz+y26+6Oynz5HJ6NX89LvSeveN4dC xdZ6GBlc2xEQX+EMB5N1t8OogLbFFb19mgyv6sLaSN1c0cQKg+yDxflO7nuwLzAlvZ67 Zyy2A8CgyDHeZZ4ZkmCyTmMIXN9TPKaF+65ob3fPDEFOGOLZKSMA+MF515vrozJd9Uej VVhg7njoNi3UY7XrY8hli6GZ0JmSC+NY20LgurRYe3rMH2ivb1auumpqTvlUrZtf7sFT MxVGi1kQueJptkvMOtNWvfEDlNXwqlqqMS/ONjxWZ/LHsvr5/KbKF/j4nZax0Z/i+Ofp F3Iw== 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 w13-v6si21918223pll.449.2018.09.04.14.59.57; Tue, 04 Sep 2018 15:00:12 -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 S1727480AbeIECZc convert rfc822-to-8bit (ORCPT + 99 others); Tue, 4 Sep 2018 22:25:32 -0400 Received: from mail.bootlin.com ([62.4.15.54]:54723 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727023AbeIECZc (ORCPT ); Tue, 4 Sep 2018 22:25:32 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 76CEB208BE; Tue, 4 Sep 2018 23:58:28 +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 shortcircuit=ham autolearn=disabled version=3.4.0 Received: from xps13 (unknown [91.224.148.103]) by mail.bootlin.com (Postfix) with ESMTPSA id BFE2A207B4; Tue, 4 Sep 2018 23:58:17 +0200 (CEST) Date: Tue, 4 Sep 2018 23:58:16 +0200 From: Miquel Raynal To: "Gustavo A. R. Silva" Cc: Josh Wu , Boris Brezillon , 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: <20180904235816.4b239b7a@xps13> In-Reply-To: <20180824010938.GA25581@embeddedor.com> References: <20180824010938.GA25581@embeddedor.com> Organization: Bootlin X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Gustavo, "Gustavo A. R. Silva" wrote on Thu, 23 Aug 2018 20:09:38 -0500: > 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 > --- Applied to nand/next. Thanks, Miquèl