aboutsummaryrefslogtreecommitdiff
path: root/net/lapb/lapb_timer.c
diff options
context:
space:
mode:
authorGustavo A. R. Silva <[email protected]>2019-04-03 10:51:10 -0700
committerDmitry Torokhov <[email protected]>2019-04-03 16:10:40 -0700
commitecdf3a965826d8d900a747f0650acb172191dc9b (patch)
treeb39ab4b9bc9212a38f7901e09a959e2806baf98d /net/lapb/lapb_timer.c
parent6d3a41ab0c37320068e28e1f9b45e4304bb30db0 (diff)
Input: evdev - use struct_size() in kzalloc() and vzalloc()
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 is not necessary, hence it is removed. This code was detected with the help of Coccinelle. Signed-off-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]>
Diffstat (limited to 'net/lapb/lapb_timer.c')
0 files changed, 0 insertions, 0 deletions