Skip to content

Commit

Permalink
drm/amd/pm: fix variable dereferenced issue in amdgpu_device_attr_cre…
Browse files Browse the repository at this point in the history
…ate()

[ Upstream commit 25e6373 ]

- fix variable ('attr') dereferenced issue.
- using condition check instead of BUG_ON().

Fixes: 4e01847 ("drm/amdgpu: optimize amdgpu device attribute code")
Cc: Dan Carpenter <[email protected]>
Signed-off-by: Yang Wang <[email protected]>
Reviewed-by: Kenneth Feng <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
Yang Wang authored and gregkh committed Sep 13, 2023
1 parent 4885624 commit 1f548c1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/gpu/drm/amd/pm/amdgpu_pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2172,15 +2172,19 @@ static int amdgpu_device_attr_create(struct amdgpu_device *adev,
uint32_t mask, struct list_head *attr_list)
{
int ret = 0;
struct device_attribute *dev_attr = &attr->dev_attr;
const char *name = dev_attr->attr.name;
enum amdgpu_device_attr_states attr_states = ATTR_STATE_SUPPORTED;
struct amdgpu_device_attr_entry *attr_entry;
struct device_attribute *dev_attr;
const char *name;

int (*attr_update)(struct amdgpu_device *adev, struct amdgpu_device_attr *attr,
uint32_t mask, enum amdgpu_device_attr_states *states) = default_attr_update;

BUG_ON(!attr);
if (!attr)
return -EINVAL;

dev_attr = &attr->dev_attr;
name = dev_attr->attr.name;

attr_update = attr->attr_update ? attr->attr_update : default_attr_update;

Expand Down

0 comments on commit 1f548c1

Please sign in to comment.