linux/drivers/gpu/drm/amd
Gustavo A. R. Silva bcb35dad1d drm/amd/powerplay/smu10_hwmgr: 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 table_size 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: Alex Deucher <alexander.deucher@amd.com>
2019-02-19 15:58:27 -05:00
..
acp drm/amdgpu: Remove wrapper layer of cgs irq handling 2018-03-21 14:36:58 -05:00
amdgpu Revert "drm/amdgpu: Fix bugs in setting CP RB/MEC DOORBELL_RANGE registers" 2019-02-19 15:58:26 -05:00
amdkfd drm/amdkfd: Optimize out sdma doorbell array in kgd2kfd_shared_resources 2019-02-18 18:00:50 -05:00
display drm/amd/display: Refactor for setup periodic interrupt. 2019-02-19 15:58:27 -05:00
include drm/amdkfd: Optimize out sdma doorbell array in kgd2kfd_shared_resources 2019-02-18 18:00:50 -05:00
lib
powerplay drm/amd/powerplay/smu10_hwmgr: use struct_size() in kzalloc() 2019-02-19 15:58:27 -05:00