Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tee: qcomtee: fix uninitialized pointers with free attribute

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>

authored by

Ally Heev and committed by
Jens Wiklander
ac5ae0a5 3a866087

+1 -1
+1 -1
drivers/tee/qcomtee/call.c
··· 645 645 static void qcomtee_get_qtee_feature_list(struct tee_context *ctx, u32 id, 646 646 u32 *version) 647 647 { 648 - struct qcomtee_object_invoke_ctx *oic __free(kfree); 648 + struct qcomtee_object_invoke_ctx *oic __free(kfree) = NULL; 649 649 struct qcomtee_object *client_env, *service; 650 650 struct qcomtee_arg u[3] = { 0 }; 651 651 int result;