diff options
author | Gustavo A. R. Silva <gustavo@embeddedor.com> | 2019-04-10 12:09:14 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2019-04-16 21:54:03 +0200 |
commit | 2d65c42b43e53d61f1fd6b8d0a097451a4cffa24 (patch) | |
tree | 3c6f04610b24a5bf4b1d4b585dff88dd42c848b9 /kernel/irq_work.c | |
parent | bbba0e7c5cdadb47a91edea1d5cd0caadbbb016f (diff) | |
download | linux-2d65c42b43e53d61f1fd6b8d0a097451a4cffa24.tar.gz linux-2d65c42b43e53d61f1fd6b8d0a097451a4cffa24.tar.bz2 linux-2d65c42b43e53d61f1fd6b8d0a097451a4cffa24.zip |
genirq/devres: Use struct_size() in devm_kzalloc()
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;
struct boo entry[];
};
size = sizeof(struct foo) + count * sizeof(struct boo);
instance = devm_kzalloc(dev, size, 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 code was detected with the help of Coccinelle.
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20190410170914.GA16161@embeddedor
Diffstat (limited to 'kernel/irq_work.c')
0 files changed, 0 insertions, 0 deletions