wifi: nl80211: convert cfg80211_scan_request allocation to *_size macros
authorJacob Keller <jacob.e.keller@intel.com>
Tue, 28 Feb 2023 16:28:27 +0000 (08:28 -0800)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 7 Mar 2023 16:13:38 +0000 (17:13 +0100)
commit14e05beb10326eeb997ec5ebbf10edf08e85c3f8
tree8f9413e78a07a43d59940c90ffd4bc6356eec0ee
parent6933486133ecf71bbe273d7ac72cfc4a51286af3
wifi: nl80211: convert cfg80211_scan_request allocation to *_size macros

The cfg80211_scan_request structure is followed by a flexible array member
as well as several other arrays that are then stored into pointers in the
structure. These are allocated currently using a simple sequence of
multiplications.

Replace the calculations with struct_size(), size_add(), and array_size()
helper macros. These macros saturate the calculation at SIZE_MAX rather
than overflowing.

Note that we can't use flex_array_size() instead of array_size() because
the fields are not arrays, but simple pointers.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Link: https://lore.kernel.org/r/20230228162827.3876606-3-jacob.e.keller@intel.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/nl80211.c