Skip to content

Commit

Permalink
[amdgpu] Fix reproducible crash when running sysctl -a (#113)
Browse files Browse the repository at this point in the history
* [amdgpu] Fix reproducible crash when running sysctl -a

When running `sysctl -a` the system immediately panics.  This is
on an Acer Aspire E5-551G with an 'AMD A10-7300 Radeon R6' APU.

```
amdgpu_get_pp_num_states() at amdgpu_get_pp_num_states+0x76/frame 0xfffffe004a9f3680
sysctl_handle_attr() at sysctl_handle_attr+0x71/frame 0xfffffe004a9f36d0
sysctl_root_handler_locked() at sysctl_root_handler_locked+0x8b/frame 0xfffffe004a9f3710
```

In amdgpu_get_pp_num_states() `adev->powerplay.pp_funcs->get_pp_num_states`
could be false, and `data` would be left uninitialized.  Always
initializing `data` to zero fixes the crash.

Signed-off-by: Tobias Kortkamp <tobik@FreeBSD.org>

* Update amdgpu_pm.c
  • Loading branch information
Tobias Kortkamp authored and johalun committed Dec 10, 2018
1 parent 132468d commit b5ef47b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
Expand Up @@ -233,6 +233,10 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,
struct pp_states_info data;
int i, buf_len;

#ifndef __linux__
/* sysctl -a can panic if this data is uninitialized */
memset(&data, 0, sizeof(struct pp_states_info));
#endif
if (adev->powerplay.pp_funcs->get_pp_num_states)
amdgpu_dpm_get_pp_num_states(adev, &data);

Expand Down

0 comments on commit b5ef47b

Please sign in to comment.