[PATCH] drm/amdgpu: Remove hidden double memset from amdgpu_cs_ioctl()
Tvrtko Ursulin
tursulin at igalia.com
Tue Aug 13 14:03:10 UTC 2024
From: Tvrtko Ursulin <tvrtko.ursulin at igalia.com>
When CONFIG_INIT_STACK_ALL_ZERO is set and so -ftrivial-auto-var-init=zero
compiler option active, compiler fails to notice that inside
amdgpu_cs_parser_init() there is a second memset to clear the same on
stack struct amdgpu_cs_parser.
If we pull this memset one level out, into the amdgpu_cs_ioctl(), compiler
can then see it and avoid clearing this struct twice.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at igalia.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 9aa952f258cf..554289eb1913 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -51,7 +51,6 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p,
if (cs->in.num_chunks == 0)
return -EINVAL;
- memset(p, 0, sizeof(*p));
p->adev = adev;
p->filp = filp;
@@ -1411,6 +1410,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
if (!adev->accel_working)
return -EBUSY;
+ memset(&parser, 0, sizeof(parser));
r = amdgpu_cs_parser_init(&parser, adev, filp, data);
if (r) {
DRM_ERROR_RATELIMITED("Failed to initialize parser %d!\n", r);
--
2.44.0
More information about the amd-gfx
mailing list