diff options
author | Gustavo A. R. Silva <gustavo@embeddedor.com> | 2019-04-03 11:46:11 -0500 |
---|---|---|
committer | Kalle Valo <kvalo@codeaurora.org> | 2019-04-13 13:58:36 +0300 |
commit | 0cf83903aad03dc7f444a47990def48c4a9d3276 (patch) | |
tree | 11d088baac276d4ef066e1e35f4c0a5ba5c5c3bf /tools/perf/scripts/python/stackcollapse.py | |
parent | 5f659c792a31c42d0b5b7a883af4b74f1d8ded0b (diff) |
brcmfmac: Use struct_size() in 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 = kzalloc(size, 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, in this case, variable reqsz is not necessary,
hence it is removed.
This code was detected with the help of Coccinelle.
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Diffstat (limited to 'tools/perf/scripts/python/stackcollapse.py')
0 files changed, 0 insertions, 0 deletions