aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorGustavo A. R. Silva <gustavo@embeddedor.com>2019-08-29 19:53:20 -0500
committerJacek Anaszewski <jacek.anaszewski@gmail.com>2019-09-01 13:33:29 +0200
commitd4b02200ae7cc5886be01c0d7f1d335f4b6966a7 (patch)
treefb3a7fb74e0dee8b78519d4331d7b25fa3a15650 /crypto
parentleds: is31fl32xx: Use struct_size() helper (diff)
downloadlinux-dev-d4b02200ae7cc5886be01c0d7f1d335f4b6966a7.tar.xz
linux-dev-d4b02200ae7cc5886be01c0d7f1d335f4b6966a7.zip
leds: pwm: Use struct_size() helper
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 led_pwm_priv { ... struct led_pwm_data leds[0]; }; Make use of the struct_size() helper instead of an open-coded version in order to avoid any potential type mistakes. So, replace the following function: static inline size_t sizeof_pwm_leds_priv(int num_leds) { return sizeof(struct led_pwm_priv) + (sizeof(struct led_pwm_data) * num_leds); } with: struct_size(priv, leds, count) This code was detected with the help of Coccinelle. Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Diffstat (limited to 'crypto')
0 files changed, 0 insertions, 0 deletions