diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2020-07-16 09:59:18 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2020-07-16 09:59:18 +0000 |
commit | eb303dc5f282d4c9aedf52440cd34a38cc553e40 (patch) | |
tree | 828087bd78ce5b8e50b5f10bb32d0be4282c51e4 /sys | |
parent | ee854d175e94d2c5ddc87233a1cef27c43a377e7 (diff) |
drm/radeon: fix double free
From Tom Rix
67e9648f20524ff6824ebeb26afea45f7d9c300d in linux 5.7.y/5.7.9
41855a898650803e24b284173354cc3e44d07725 in mainline linux
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/pci/drm/radeon/ci_dpm.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/sys/dev/pci/drm/radeon/ci_dpm.c b/sys/dev/pci/drm/radeon/ci_dpm.c index a9257bed348..30b5a59353c 100644 --- a/sys/dev/pci/drm/radeon/ci_dpm.c +++ b/sys/dev/pci/drm/radeon/ci_dpm.c @@ -5577,6 +5577,7 @@ static int ci_parse_power_table(struct radeon_device *rdev) if (!rdev->pm.dpm.ps) return -ENOMEM; power_state_offset = (u8 *)state_array->states; + rdev->pm.dpm.num_ps = 0; for (i = 0; i < state_array->ucNumEntries; i++) { u8 *idx; power_state = (union pplib_power_state *)power_state_offset; @@ -5586,10 +5587,8 @@ static int ci_parse_power_table(struct radeon_device *rdev) if (!rdev->pm.power_state[i].clock_info) return -EINVAL; ps = kzalloc(sizeof(struct ci_ps), GFP_KERNEL); - if (ps == NULL) { - kfree(rdev->pm.dpm.ps); + if (ps == NULL) return -ENOMEM; - } rdev->pm.dpm.ps[i].ps_priv = ps; ci_parse_pplib_non_clock_info(rdev, &rdev->pm.dpm.ps[i], non_clock_info, @@ -5611,8 +5610,8 @@ static int ci_parse_power_table(struct radeon_device *rdev) k++; } power_state_offset += 2 + power_state->v2.ucNumDPMLevels; + rdev->pm.dpm.num_ps = i + 1; } - rdev->pm.dpm.num_ps = state_array->ucNumEntries; /* fill in the vce power states */ for (i = 0; i < RADEON_MAX_VCE_LEVELS; i++) { |