Re: [PATCH] drm/panthor: avoid garbage value in panthor_ioctl_dev_query()

From: Su Hui
Date: Mon Jan 20 2025 - 03:43:02 EST


On 2025/1/20 15:21, Dan Carpenter wrote:
On Sun, Jan 19, 2025 at 10:58:29AM +0800, Su Hui wrote:
'priorities_info' is uninitialized, and the uninitialized value is copied
to user object when calling PANTHOR_UOBJ_SET(). Using memset to initialize
'priorities_info' to avoid this garbage value problem.

Fixes: f70000ef2352 ("drm/panthor: Add DEV_QUERY_GROUP_PRIORITIES_INFO dev query")
Signed-off-by: Su Hui <suhui@xxxxxxxxxxxx>
Reviewed-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

How did you find this bug?
Clang found this bug, run command like this:
scan-build  --use-cc=clang    make CC=clang drivers/gpu/drm/panthor/panthor_drv.o

There will be some warnings, one is this:
drivers/gpu/drm/panthor/panthor_drv.c:807:22: warning: The left expression of the compound
assignment is an uninitialized value. The computed value will also be garbage [core.uninitialized.Assign]
  807 |                         arg->allowed_mask |= BIT(prio);
      |                         ~~~~~~~~~~~~~~~~~ ^


regards,
su hui