WSL2-Linux-Kernel/drivers/gpu/drm/radeon
Tom Rix 41855a8986 drm/radeon: fix double free
clang static analysis flags this error

drivers/gpu/drm/radeon/ci_dpm.c:5652:9: warning: Use of memory after it is freed [unix.Malloc]
                kfree(rdev->pm.dpm.ps[i].ps_priv);
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/radeon/ci_dpm.c:5654:2: warning: Attempt to free released memory [unix.Malloc]
        kfree(rdev->pm.dpm.ps);
        ^~~~~~~~~~~~~~~~~~~~~~

problem is reported in ci_dpm_fini, with these code blocks.

	for (i = 0; i < rdev->pm.dpm.num_ps; i++) {
		kfree(rdev->pm.dpm.ps[i].ps_priv);
	}
	kfree(rdev->pm.dpm.ps);

The first free happens in ci_parse_power_table where it cleans up locally
on a failure.  ci_dpm_fini also does a cleanup.

	ret = ci_parse_power_table(rdev);
	if (ret) {
		ci_dpm_fini(rdev);
		return ret;
	}

So remove the cleanup in ci_parse_power_table and
move the num_ps calculation to inside the loop so ci_dpm_fini
will know how many array elements to free.

Fixes: cc8dbbb4f6 ("drm/radeon: add dpm support for CI dGPUs (v2)")

Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
2020-07-09 14:42:49 -04:00
..
reg_srcs
.gitignore
Kconfig
Makefile
ObjectID.h
atom-bits.h
atom-names.h
atom-types.h
atom.c drm/radeon: cleanup coding style a bit 2020-04-30 16:48:42 -04:00
atom.h
atombios.h
atombios_crtc.c
atombios_dp.c
atombios_encoders.c
atombios_i2c.c
avivod.h
btc_dpm.c
btc_dpm.h
btcd.h
cayman_blit_shaders.c
cayman_blit_shaders.h
ci_dpm.c drm/radeon: fix double free 2020-07-09 14:42:49 -04:00
ci_dpm.h
ci_smc.c
cik.c
cik_blit_shaders.c
cik_blit_shaders.h
cik_reg.h
cik_sdma.c
cikd.h
clearstate_cayman.h
clearstate_ci.h
clearstate_defs.h
clearstate_evergreen.h
clearstate_si.h
cypress_dpm.c
cypress_dpm.h
dce3_1_afmt.c
dce6_afmt.c
evergreen.c
evergreen_blit_shaders.c
evergreen_blit_shaders.h
evergreen_cs.c
evergreen_dma.c
evergreen_hdmi.c
evergreen_reg.h
evergreen_smc.h
evergreend.h
kv_dpm.c
kv_dpm.h
kv_smc.c
mkregtable.c
ni.c
ni_dma.c
ni_dpm.c drm/radeon: fix fb_div check in ni_init_smc_spll_table() 2020-06-24 10:34:48 -04:00
ni_dpm.h
ni_reg.h
nid.h
nislands_smc.h
ppsmc.h
pptable.h
r100.c
r100_track.h
r100d.h
r200.c
r300.c
r300_reg.h
r300d.h
r420.c
r420d.h
r500_reg.h
r520.c
r520d.h
r600.c
r600_blit_shaders.c
r600_blit_shaders.h
r600_cs.c
r600_dma.c
r600_dpm.c
r600_dpm.h
r600_hdmi.c
r600_reg.h
r600d.h
radeon.h
radeon_acpi.c
radeon_acpi.h
radeon_agp.c
radeon_asic.c
radeon_asic.h
radeon_atombios.c
radeon_atpx_handler.c
radeon_audio.c
radeon_audio.h
radeon_benchmark.c
radeon_bios.c
radeon_clocks.c
radeon_combios.c
radeon_connectors.c
radeon_cs.c mmap locking API: use coccinelle to convert mmap_sem rwsem call sites 2020-06-09 09:39:14 -07:00
radeon_cursor.c
radeon_device.c
radeon_display.c
radeon_dp_auxch.c
radeon_dp_mst.c
radeon_drv.c
radeon_drv.h
radeon_encoders.c
radeon_family.h
radeon_fb.c
radeon_fence.c
radeon_gart.c
radeon_gem.c mmap locking API: use coccinelle to convert mmap_sem rwsem call sites 2020-06-09 09:39:14 -07:00
radeon_i2c.c
radeon_ib.c
radeon_irq_kms.c
radeon_kms.c drm pull for 5.8-rc1 2020-06-02 15:04:15 -07:00
radeon_legacy_crtc.c
radeon_legacy_encoders.c
radeon_legacy_tv.c
radeon_mn.c
radeon_mode.h
radeon_object.c
radeon_object.h
radeon_pm.c
radeon_prime.c
radeon_reg.h
radeon_ring.c
radeon_sa.c
radeon_semaphore.c
radeon_sync.c
radeon_test.c
radeon_trace.h
radeon_trace_points.c
radeon_ttm.c
radeon_ucode.c
radeon_ucode.h
radeon_uvd.c
radeon_vce.c
radeon_vm.c
rs100d.h
rs400.c
rs400d.h
rs600.c
rs600d.h
rs690.c
rs690d.h
rs780_dpm.c
rs780_dpm.h
rs780d.h
rv6xx_dpm.c
rv6xx_dpm.h
rv6xxd.h
rv200d.h
rv250d.h
rv350d.h
rv515.c
rv515d.h
rv730_dpm.c
rv730d.h
rv740_dpm.c
rv740d.h
rv770.c
rv770_dma.c
rv770_dpm.c
rv770_dpm.h
rv770_smc.c
rv770_smc.h
rv770d.h
si.c
si_blit_shaders.c
si_blit_shaders.h
si_dma.c
si_dpm.c
si_dpm.h
si_reg.h
si_smc.c
sid.h
sislands_smc.h
smu7.h
smu7_discrete.h
smu7_fusion.h
sumo_dpm.c
sumo_dpm.h
sumo_smc.c
sumod.h
trinity_dpm.c
trinity_dpm.h
trinity_smc.c
trinityd.h
uvd_v1_0.c
uvd_v2_2.c
uvd_v3_1.c
uvd_v4_2.c
vce_v1_0.c
vce_v2_0.c