mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
![]() The vzalloc() function has no 2-factor argument form, so multiplication factors need to be wrapped in array_size(). This patch replaces cases of: vzalloc(a * b) with: vzalloc(array_size(a, b)) as well as handling cases of: vzalloc(a * b * c) with: vzalloc(array3_size(a, b, c)) This does, however, attempt to ignore constant size factors like: vzalloc(4 * 1024) though any constants defined via macros get caught up in the conversion. Any factors with a sizeof() of "unsigned char", "char", and "u8" were dropped, since they're redundant. The Coccinelle script used for this was: // Fix redundant parens around sizeof(). @@ type TYPE; expression THING, E; @@ ( vzalloc( - (sizeof(TYPE)) * E + sizeof(TYPE) * E , ...) | vzalloc( - (sizeof(THING)) * E + sizeof(THING) * E , ...) ) // Drop single-byte sizes and redundant parens. @@ expression COUNT; typedef u8; typedef __u8; @@ ( vzalloc( - sizeof(u8) * (COUNT) + COUNT , ...) | vzalloc( - sizeof(__u8) * (COUNT) + COUNT , ...) | vzalloc( - sizeof(char) * (COUNT) + COUNT , ...) | vzalloc( - sizeof(unsigned char) * (COUNT) + COUNT , ...) | vzalloc( - sizeof(u8) * COUNT + COUNT , ...) | vzalloc( - sizeof(__u8) * COUNT + COUNT , ...) | vzalloc( - sizeof(char) * COUNT + COUNT , ...) | vzalloc( - sizeof(unsigned char) * COUNT + COUNT , ...) ) // 2-factor product with sizeof(type/expression) and identifier or constant. @@ type TYPE; expression THING; identifier COUNT_ID; constant COUNT_CONST; @@ ( vzalloc( - sizeof(TYPE) * (COUNT_ID) + array_size(COUNT_ID, sizeof(TYPE)) , ...) | vzalloc( - sizeof(TYPE) * COUNT_ID + array_size(COUNT_ID, sizeof(TYPE)) , ...) | vzalloc( - sizeof(TYPE) * (COUNT_CONST) + array_size(COUNT_CONST, sizeof(TYPE)) , ...) | vzalloc( - sizeof(TYPE) * COUNT_CONST + array_size(COUNT_CONST, sizeof(TYPE)) , ...) | vzalloc( - sizeof(THING) * (COUNT_ID) + array_size(COUNT_ID, sizeof(THING)) , ...) | vzalloc( - sizeof(THING) * COUNT_ID + array_size(COUNT_ID, sizeof(THING)) , ...) | vzalloc( - sizeof(THING) * (COUNT_CONST) + array_size(COUNT_CONST, sizeof(THING)) , ...) | vzalloc( - sizeof(THING) * COUNT_CONST + array_size(COUNT_CONST, sizeof(THING)) , ...) ) // 2-factor product, only identifiers. @@ identifier SIZE, COUNT; @@ vzalloc( - SIZE * COUNT + array_size(COUNT, SIZE) , ...) // 3-factor product with 1 sizeof(type) or sizeof(expression), with // redundant parens removed. @@ expression THING; identifier STRIDE, COUNT; type TYPE; @@ ( vzalloc( - sizeof(TYPE) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | vzalloc( - sizeof(TYPE) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | vzalloc( - sizeof(TYPE) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | vzalloc( - sizeof(TYPE) * COUNT * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | vzalloc( - sizeof(THING) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | vzalloc( - sizeof(THING) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | vzalloc( - sizeof(THING) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | vzalloc( - sizeof(THING) * COUNT * STRIDE + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) ) // 3-factor product with 2 sizeof(variable), with redundant parens removed. @@ expression THING1, THING2; identifier COUNT; type TYPE1, TYPE2; @@ ( vzalloc( - sizeof(TYPE1) * sizeof(TYPE2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | vzalloc( - sizeof(TYPE1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | vzalloc( - sizeof(THING1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | vzalloc( - sizeof(THING1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | vzalloc( - sizeof(TYPE1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2)) , ...) | vzalloc( - sizeof(TYPE1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2)) , ...) ) // 3-factor product, only identifiers, with redundant parens removed. @@ identifier STRIDE, SIZE, COUNT; @@ ( vzalloc( - (COUNT) * STRIDE * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | vzalloc( - COUNT * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | vzalloc( - COUNT * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | vzalloc( - (COUNT) * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | vzalloc( - COUNT * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | vzalloc( - (COUNT) * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | vzalloc( - (COUNT) * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | vzalloc( - COUNT * STRIDE * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) ) // Any remaining multi-factor products, first at least 3-factor products // when they're not all constants... @@ expression E1, E2, E3; constant C1, C2, C3; @@ ( vzalloc(C1 * C2 * C3, ...) | vzalloc( - E1 * E2 * E3 + array3_size(E1, E2, E3) , ...) ) // And then all remaining 2 factors products when they're not all constants. @@ expression E1, E2; constant C1, C2; @@ ( vzalloc(C1 * C2, ...) | vzalloc( - E1 * E2 + array_size(E1, E2) , ...) ) Signed-off-by: Kees Cook <keescook@chromium.org> |
||
---|---|---|
.. | ||
amdgpu.h | ||
amdgpu_acp.c | ||
amdgpu_acp.h | ||
amdgpu_acpi.c | ||
amdgpu_afmt.c | ||
amdgpu_amdkfd.c | ||
amdgpu_amdkfd.h | ||
amdgpu_amdkfd_fence.c | ||
amdgpu_amdkfd_gfx_v7.c | ||
amdgpu_amdkfd_gfx_v8.c | ||
amdgpu_amdkfd_gfx_v9.c | ||
amdgpu_amdkfd_gpuvm.c | ||
amdgpu_atombios.c | ||
amdgpu_atombios.h | ||
amdgpu_atomfirmware.c | ||
amdgpu_atomfirmware.h | ||
amdgpu_atpx_handler.c | ||
amdgpu_benchmark.c | ||
amdgpu_bios.c | ||
amdgpu_bo_list.c | ||
amdgpu_cgs.c | ||
amdgpu_connectors.c | ||
amdgpu_connectors.h | ||
amdgpu_cs.c | ||
amdgpu_ctx.c | ||
amdgpu_debugfs.c | ||
amdgpu_debugfs.h | ||
amdgpu_device.c | ||
amdgpu_display.c | ||
amdgpu_display.h | ||
amdgpu_dpm.c | ||
amdgpu_dpm.h | ||
amdgpu_drv.c | ||
amdgpu_drv.h | ||
amdgpu_encoders.c | ||
amdgpu_fb.c | ||
amdgpu_fence.c | ||
amdgpu_gart.c | ||
amdgpu_gart.h | ||
amdgpu_gds.h | ||
amdgpu_gem.c | ||
amdgpu_gfx.c | ||
amdgpu_gfx.h | ||
amdgpu_gmc.h | ||
amdgpu_gtt_mgr.c | ||
amdgpu_i2c.c | ||
amdgpu_i2c.h | ||
amdgpu_ib.c | ||
amdgpu_ids.c | ||
amdgpu_ids.h | ||
amdgpu_ih.c | ||
amdgpu_ih.h | ||
amdgpu_ioc32.c | ||
amdgpu_irq.c | ||
amdgpu_irq.h | ||
amdgpu_job.c | ||
amdgpu_kms.c | ||
amdgpu_mn.c | ||
amdgpu_mn.h | ||
amdgpu_mode.h | ||
amdgpu_object.c | ||
amdgpu_object.h | ||
amdgpu_pll.c | ||
amdgpu_pll.h | ||
amdgpu_pm.c | ||
amdgpu_pm.h | ||
amdgpu_prime.c | ||
amdgpu_psp.c | ||
amdgpu_psp.h | ||
amdgpu_queue_mgr.c | ||
amdgpu_ring.c | ||
amdgpu_ring.h | ||
amdgpu_sa.c | ||
amdgpu_sched.c | ||
amdgpu_sched.h | ||
amdgpu_sync.c | ||
amdgpu_sync.h | ||
amdgpu_test.c | ||
amdgpu_trace.h | ||
amdgpu_trace_points.c | ||
amdgpu_ttm.c | ||
amdgpu_ttm.h | ||
amdgpu_ucode.c | ||
amdgpu_ucode.h | ||
amdgpu_uvd.c | ||
amdgpu_uvd.h | ||
amdgpu_vce.c | ||
amdgpu_vce.h | ||
amdgpu_vcn.c | ||
amdgpu_vcn.h | ||
amdgpu_vf_error.c | ||
amdgpu_vf_error.h | ||
amdgpu_virt.c | ||
amdgpu_virt.h | ||
amdgpu_vm.c | ||
amdgpu_vm.h | ||
amdgpu_vram_mgr.c | ||
atom.c | ||
atom.h | ||
atombios_crtc.c | ||
atombios_crtc.h | ||
atombios_dp.c | ||
atombios_dp.h | ||
atombios_encoders.c | ||
atombios_encoders.h | ||
atombios_i2c.c | ||
atombios_i2c.h | ||
ci_dpm.c | ||
ci_dpm.h | ||
ci_smc.c | ||
cik.c | ||
cik.h | ||
cik_dpm.h | ||
cik_ih.c | ||
cik_ih.h | ||
cik_sdma.c | ||
cik_sdma.h | ||
cikd.h | ||
clearstate_ci.h | ||
clearstate_defs.h | ||
clearstate_gfx9.h | ||
clearstate_si.h | ||
clearstate_vi.h | ||
cz_ih.c | ||
cz_ih.h | ||
dce_v6_0.c | ||
dce_v6_0.h | ||
dce_v8_0.c | ||
dce_v8_0.h | ||
dce_v10_0.c | ||
dce_v10_0.h | ||
dce_v11_0.c | ||
dce_v11_0.h | ||
dce_virtual.c | ||
dce_virtual.h | ||
df_v1_7.c | ||
df_v1_7.h | ||
df_v3_6.c | ||
df_v3_6.h | ||
emu_soc.c | ||
gfx_v6_0.c | ||
gfx_v6_0.h | ||
gfx_v7_0.c | ||
gfx_v7_0.h | ||
gfx_v8_0.c | ||
gfx_v8_0.h | ||
gfx_v9_0.c | ||
gfx_v9_0.h | ||
gfxhub_v1_0.c | ||
gfxhub_v1_0.h | ||
gmc_v6_0.c | ||
gmc_v6_0.h | ||
gmc_v7_0.c | ||
gmc_v7_0.h | ||
gmc_v8_0.c | ||
gmc_v8_0.h | ||
gmc_v9_0.c | ||
gmc_v9_0.h | ||
iceland_ih.c | ||
iceland_ih.h | ||
iceland_sdma_pkt_open.h | ||
Kconfig | ||
kv_dpm.c | ||
kv_dpm.h | ||
kv_smc.c | ||
Makefile | ||
mmhub_v1_0.c | ||
mmhub_v1_0.h | ||
mmsch_v1_0.h | ||
mxgpu_ai.c | ||
mxgpu_ai.h | ||
mxgpu_vi.c | ||
mxgpu_vi.h | ||
nbio_v6_1.c | ||
nbio_v6_1.h | ||
nbio_v7_0.c | ||
nbio_v7_0.h | ||
ObjectID.h | ||
ppsmc.h | ||
psp_gfx_if.h | ||
psp_v3_1.c | ||
psp_v3_1.h | ||
psp_v10_0.c | ||
psp_v10_0.h | ||
r600_dpm.h | ||
sdma_v2_4.c | ||
sdma_v2_4.h | ||
sdma_v3_0.c | ||
sdma_v3_0.h | ||
sdma_v4_0.c | ||
sdma_v4_0.h | ||
si.c | ||
si.h | ||
si_dma.c | ||
si_dma.h | ||
si_dpm.c | ||
si_dpm.h | ||
si_enums.h | ||
si_ih.c | ||
si_ih.h | ||
si_smc.c | ||
sid.h | ||
sislands_smc.h | ||
soc15.c | ||
soc15.h | ||
soc15_common.h | ||
soc15d.h | ||
tonga_ih.c | ||
tonga_ih.h | ||
tonga_sdma_pkt_open.h | ||
uvd_v4_2.c | ||
uvd_v4_2.h | ||
uvd_v5_0.c | ||
uvd_v5_0.h | ||
uvd_v6_0.c | ||
uvd_v6_0.h | ||
uvd_v7_0.c | ||
uvd_v7_0.h | ||
vce_v2_0.c | ||
vce_v2_0.h | ||
vce_v3_0.c | ||
vce_v3_0.h | ||
vce_v4_0.c | ||
vce_v4_0.h | ||
vcn_v1_0.c | ||
vcn_v1_0.h | ||
vega10_ih.c | ||
vega10_ih.h | ||
vega10_reg_init.c | ||
vega10_sdma_pkt_open.h | ||
vega20_reg_init.c | ||
vi.c | ||
vi.h | ||
vi_dpm.h | ||
vid.h |