diff options
author | Gustavo A. R. Silva <gustavo@embeddedor.com> | 2019-04-03 18:31:51 +0300 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2019-04-26 14:02:11 +0300 |
commit | 9f8c7136e8aa92a334ef2fc92dd6b5bbd23886da (patch) | |
tree | 056efec08b902a9efc0a653e92398494318a7548 /net/mac80211 | |
parent | 276d9e82e06cade9c4d081664ad63da1be971642 (diff) | |
download | linux-9f8c7136e8aa92a334ef2fc92dd6b5bbd23886da.tar.xz |
cfg80211: 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 size_of_regd 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: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211')
0 files changed, 0 insertions, 0 deletions