Tom Rix 99010fac8b 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: cc8dbbb4f62a ("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>
2020-07-08 09:04:25 -04:00
..
2020-04-30 16:48:42 -04:00
2020-02-17 10:34:34 +01:00
2019-12-18 16:09:13 -05:00
2020-07-08 09:04:25 -04:00
2019-06-10 22:30:24 +02:00
2019-06-10 22:30:24 +02:00
2020-04-01 14:44:43 -04:00
2019-06-10 22:30:24 +02:00
2019-06-10 22:30:24 +02:00
2020-06-24 15:45:51 +10:00
2020-06-24 15:45:51 +10:00
2020-06-25 11:58:49 +02:00
2019-06-10 22:30:24 +02:00
2019-06-10 22:30:24 +02:00
2019-06-10 22:30:24 +02:00