Commit 62cc895c authored by Dan Carpenter's avatar Dan Carpenter Committed by Alex Deucher

drm/amdgpu: off by one in amdgpu_device_attr_create_groups() error handling

This loop in the error handling code should start a "i - 1" and end at
"i == 0".  Currently it starts a "i" and ends at "i == 1".  The result
is that it removes one attribute that wasn't created yet, and leaks the
zeroeth attribute.

Fixes: 4e01847c ("drm/amdgpu: optimize amdgpu device attribute code")
Acked-by: default avatarMichael J. Ruhl <michael.j.ruhl@intel.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarKevin Wang <kevin1.wang@amd.com>
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 94f2026b
...@@ -1837,9 +1837,8 @@ static int amdgpu_device_attr_create_groups(struct amdgpu_device *adev, ...@@ -1837,9 +1837,8 @@ static int amdgpu_device_attr_create_groups(struct amdgpu_device *adev,
return 0; return 0;
failed: failed:
for (; i > 0; i--) { while (i--)
amdgpu_device_attr_remove(adev, &attrs[i]); amdgpu_device_attr_remove(adev, &attrs[i]);
}
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment