From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Stephen Boyd <sboyd@kernel.org>,
Fabio Estevam <fabio.estevam@nxp.com>,
Michael Turquette <mturquette@baylibre.com>,
NXP Linux Team <linux-imx@nxp.com>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Sascha Hauer <s.hauer@pengutronix.de>,
Shawn Guo <shawnguo@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] clk: imx: imx7ulp: use struct_size() in kzalloc()
Date: Thu, 24 Jan 2019 13:39:10 -0600 [thread overview]
Message-ID: <50cb397d-5e41-834d-3a6d-00e1c4efb042@embeddedor.com> (raw)
In-Reply-To: <154835867687.136743.9650857344780789822@swboyd.mtv.corp.google.com>
On 1/24/19 1:37 PM, Stephen Boyd wrote:
> Quoting Gustavo A. R. Silva (2018-12-23 22:40:25)
>> 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);
>>
>> This issue was detected with the help of Coccinelle.
>>
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>> ---
>
> Applied to clk-next
>
Thanks, Stephen.
--
Gustavo
prev parent reply other threads:[~2019-01-24 20:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-24 6:40 [PATCH] clk: imx: imx7ulp: use struct_size() in kzalloc() Gustavo A. R. Silva
2018-12-24 9:03 ` Aisheng Dong
2019-01-14 16:44 ` Gustavo A. R. Silva
2019-01-24 19:37 ` Stephen Boyd
2019-01-24 19:39 ` Gustavo A. R. Silva [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=50cb397d-5e41-834d-3a6d-00e1c4efb042@embeddedor.com \
--to=gustavo@embeddedor.com \
--cc=fabio.estevam@nxp.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=s.hauer@pengutronix.de \
--cc=sboyd@kernel.org \
--cc=shawnguo@kernel.org \
/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).