]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
tee: qcomtee: fix uninitialized pointers with free attribute
authorAlly Heev <allyheev@gmail.com>
Tue, 11 Nov 2025 07:56:42 +0000 (13:26 +0530)
committerJens Wiklander <jens.wiklander@linaro.org>
Fri, 14 Nov 2025 07:42:07 +0000 (08:42 +0100)
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.

qcomtee doesn't have any bugs related to this as of now, but
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@linaro.org>
Closes: https://lore.kernel.org/all/aPiG_F5EBQUjZqsl@stanley.mountain/
Signed-off-by: Ally Heev <allyheev@gmail.com>
Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
drivers/tee/qcomtee/call.c

index cc17a48d0ab74e77d39682954f2a6017181d4a72..92e869f7467d8fd7abbdb9d281852f5e4a28def4 100644 (file)
@@ -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;