diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2023-09-13 12:55:19 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2023-09-13 12:55:19 +0000 |
commit | 3dd3eac049b34d1a80cbf8704c1b8d75348eb546 (patch) | |
tree | 6845c5a3cd4c38a9b151d0321f3522a28df0607c /sys/dev | |
parent | 5d88b7e9498f18625a29de788c39b8663be7cfc0 (diff) |
drm/amd/pm: fix variable dereferenced issue in amdgpu_device_attr_create()
From Yang Wang
f27dff881f0b8f1a5bc64d48a19802dd520bc482 in linux-6.1.y/6.1.53
25e6373a5b8efc623443f2699d2b929bf3067d76 in mainline linux
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/drm/amd/pm/amdgpu_pm.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/dev/pci/drm/amd/pm/amdgpu_pm.c b/sys/dev/pci/drm/amd/pm/amdgpu_pm.c index ef5f21e3ffa..134bdb4a68f 100644 --- a/sys/dev/pci/drm/amd/pm/amdgpu_pm.c +++ b/sys/dev/pci/drm/amd/pm/amdgpu_pm.c @@ -2074,15 +2074,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; |