Hello Kevin Wang,

This is a semi-automatic email about new static checker warnings.

The patch 4e01847c38f7: "drm/amdgpu: optimize amdgpu device attribute 
code" from Apr 27, 2020, leads to the following Smatch complaint:

    ./drivers/gpu/drm/amd/pm/amdgpu_pm.c:2182 amdgpu_device_attr_create()
    warn: variable dereferenced before check 'attr' (see line 2175)

./drivers/gpu/drm/amd/pm/amdgpu_pm.c
  2174          struct device_attribute *dev_attr = &attr->dev_attr;
  2175          const char *name = dev_attr->attr.name;
                                   ^^^^^^^^^^
Dereferenced.

  2176          enum amdgpu_device_attr_states attr_states = 
ATTR_STATE_SUPPORTED;
  2177          struct amdgpu_device_attr_entry *attr_entry;
  2178  
  2179          int (*attr_update)(struct amdgpu_device *adev, struct 
amdgpu_device_attr *attr,
  2180                             uint32_t mask, enum 
amdgpu_device_attr_states *states) = default_attr_update;
  2181  
  2182          BUG_ON(!attr);

Checked to late.  Also doesn't checkpatch warn about this?  Calling
BUG_ON() here is not correct.

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

regards,
dan carpenter

Reply via email to