diff options
author | Gustavo A. R. Silva <gustavo@embeddedor.com> | 2019-04-03 15:50:43 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-04-16 13:44:30 +0200 |
commit | e291fa1237a74dc4692995a4a598d4818a747191 (patch) | |
tree | d6a33a3c506686347065ba134e6bc659d2161b23 /drivers/staging/mt7621-pci-phy | |
parent | 3b706841c29f1cf2f8f3484713288aa2c375677b (diff) | |
download | talos-op-linux-e291fa1237a74dc4692995a4a598d4818a747191.tar.gz talos-op-linux-e291fa1237a74dc4692995a4a598d4818a747191.zip |
staging: ralink-gdma: 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:
size = struct_size(instance, entry, count);
or
instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL)
Based on the above, replace gdma_dma_alloc_desc() with kzalloc() and
use the new struct_size() helper.
This code was detected with the help of Coccinelle.
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/mt7621-pci-phy')
0 files changed, 0 insertions, 0 deletions