Re: [PATCH v2] tee: fix uninitialized pointers with free attribute

From: Sumit Garg
Date: Tue Nov 11 2025 - 01:48:47 EST


On Mon, Nov 10, 2025 at 08:47:30PM +0530, Ally Heev wrote:

For the subject, try to follow the convention:

tee: qcomtee: fix ...

> Uninitialized pointers with `__free` attribute can cause undefined
> behavior as the memory assigned randomly to the pointer is freed
> automatically when the pointer goes out of scope.
>
> tee doesn't have any bugs related to this as of now, but

s/tee/qcomtee/

> it is better to initialize and assign pointers with `__free`
> attribute in one statement to ensure proper scope-based cleanup
>
> Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> Closes: https://lore.kernel.org/all/aPiG_F5EBQUjZqsl@stanley.mountain/
> Signed-off-by: Ally Heev <allyheev@xxxxxxxxx>
> ---
> Changes in v2:
> - initializing variables to NULL at the declaration
> - Link to v1: https://lore.kernel.org/r/20251105-aheev-uninitialized-free-attr-tee-v1-1-2e1ee8483bc5@xxxxxxxxx
> ---
> drivers/tee/qcomtee/call.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/tee/qcomtee/call.c b/drivers/tee/qcomtee/call.c
> index ac134452cc9cfd384c28d41547545f2c5748d86c..65f9140d4e1f8909d072004fd24730543e320d74 100644
> --- a/drivers/tee/qcomtee/call.c
> +++ b/drivers/tee/qcomtee/call.c
> @@ -645,7 +645,7 @@ static void qcomtee_get_version(struct tee_device *teedev,
> static void qcomtee_get_qtee_feature_list(struct tee_context *ctx, u32 id,
> u32 *version)
> {
> - struct qcomtee_object_invoke_ctx *oic __free(kfree);
> + struct qcomtee_object_invoke_ctx *oic __free(kfree) = NULL;
> struct qcomtee_object *client_env, *service;
> struct qcomtee_arg u[3] = { 0 };
> int result;
>

The change itself looks fine to me.

-Sumit

> ---
> base-commit: c9cfc122f03711a5124b4aafab3211cf4d35a2ac
> change-id: 20251105-aheev-uninitialized-free-attr-tee-0221e45ec5a2
>
> Best regards,
> --
> Ally Heev <allyheev@xxxxxxxxx>
>