linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@kernel.org>
To: "Gustavo A. R. Silva" <gustavo@embeddedor.com>,
	Avi Fishman <avifishman70@gmail.com>,
	Brendan Higgins <brendanhiggins@google.com>,
	Michael Turquette <mturquette@baylibre.com>,
	Nancy Yuen <yuenn@google.com>,
	Patrick Venture <venture@google.com>,
	Tomer Maimon <tmaimon77@gmail.com>
Cc: openbmc@lists.ozlabs.org, linux-clk@vger.kernel.org,
	linux-kernel@vger.kernel.org, Kees Cook <keescook@chromium.org>,
	"Gustavo A. R. Silva" <gustavo@embeddedor.com>
Subject: Re: [PATCH] clk: npcm7xx: fix memory allocation
Date: Tue, 28 Aug 2018 15:13:27 -0700	[thread overview]
Message-ID: <153549440786.129321.7169734992268309360@swboyd.mtv.corp.google.com> (raw)
In-Reply-To: <20180823230654.GA11576@embeddedor.com>

Quoting Gustavo A. R. Silva (2018-08-23 16:06:54)
> 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 = kzalloc(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 = kzalloc(struct_size(instance, entry, count), GFP_KERNEL);
> 
> Notice that, currently, there is a bug during the allocation:
>         
> sizeof(npcm7xx_clk_data) should be sizeof(*npcm7xx_clk_data)
> 
> Fix this bug by using struct_size() in kzalloc()
> 
> This issue was detected with the help of Coccinelle.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---

Applied to clk-fixes


      parent reply	other threads:[~2018-08-28 22:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-23 23:06 [PATCH] clk: npcm7xx: fix memory allocation Gustavo A. R. Silva
2018-08-23 23:17 ` Kees Cook
2018-08-26 14:03   ` Avi Fishman
2018-08-28 22:13 ` Stephen Boyd [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=153549440786.129321.7169734992268309360@swboyd.mtv.corp.google.com \
    --to=sboyd@kernel.org \
    --cc=avifishman70@gmail.com \
    --cc=brendanhiggins@google.com \
    --cc=gustavo@embeddedor.com \
    --cc=keescook@chromium.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=openbmc@lists.ozlabs.org \
    --cc=tmaimon77@gmail.com \
    --cc=venture@google.com \
    --cc=yuenn@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).