aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/nl80211.c
diff options
context:
space:
mode:
authorGustavo A. R. Silva <gustavo@embeddedor.com>2019-04-03 10:31:51 -0500
committerJohannes Berg <johannes.berg@intel.com>2019-04-26 13:02:11 +0200
commit9f8c7136e8aa92a334ef2fc92dd6b5bbd23886da (patch)
tree056efec08b902a9efc0a653e92398494318a7548 /net/wireless/nl80211.c
parentmac80211: debugfs option to force TX status frames (diff)
downloadlinux-dev-9f8c7136e8aa92a334ef2fc92dd6b5bbd23886da.tar.xz
linux-dev-9f8c7136e8aa92a334ef2fc92dd6b5bbd23886da.zip
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/wireless/nl80211.c')
0 files changed, 0 insertions, 0 deletions