[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <153549440786.129321.7169734992268309360@swboyd.mtv.corp.google.com>
Date: Tue, 28 Aug 2018 15:13:27 -0700
From: Stephen Boyd <sboyd@...nel.org>
To: "Gustavo A. R. Silva" <gustavo@...eddedor.com>,
Avi Fishman <avifishman70@...il.com>,
Brendan Higgins <brendanhiggins@...gle.com>,
Michael Turquette <mturquette@...libre.com>,
Nancy Yuen <yuenn@...gle.com>,
Patrick Venture <venture@...gle.com>,
Tomer Maimon <tmaimon77@...il.com>
Cc: openbmc@...ts.ozlabs.org, linux-clk@...r.kernel.org,
linux-kernel@...r.kernel.org, Kees Cook <keescook@...omium.org>,
"Gustavo A. R. Silva" <gustavo@...eddedor.com>
Subject: Re: [PATCH] clk: npcm7xx: fix memory allocation
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@...r.kernel.org
> Signed-off-by: Gustavo A. R. Silva <gustavo@...eddedor.com>
> ---
Applied to clk-fixes
Powered by blists - more mailing lists