Skip to content

Commit 7c4c14a

Browse files
krzkjenswi-linaro
authored andcommitted
tee: qcomtee: mem: Fix confusing cleanup.h syntax
Initializing automatic __free variables to NULL without need (e.g. branches with different allocations), followed by actual allocation is in contrary to explicit coding rules guiding cleanup.h: "Given that the "__free(...) = NULL" pattern for variables defined at the top of the function poses this potential interdependency problem the recommendation is to always define and assign variables in one statement and not group variable definitions at the top of the function when __free() is used." Code does not have a bug, but is less readable and uses discouraged coding practice, so fix that by moving declaration to the place of assignment. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Reviewed-by: Amirreza Zarrabi <amirreza.zarrabi@oss.qualcomm.com> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
1 parent 4cc1951 commit 7c4c14a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/tee/qcomtee/mem_obj.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ int qcomtee_memobj_param_to_object(struct qcomtee_object **object,
8888
struct tee_param *param,
8989
struct tee_context *ctx)
9090
{
91-
struct qcomtee_mem_object *mem_object __free(kfree) = NULL;
9291
struct tee_shm *shm;
9392
int err;
9493

95-
mem_object = kzalloc(sizeof(*mem_object), GFP_KERNEL);
94+
struct qcomtee_mem_object *mem_object __free(kfree) = kzalloc(sizeof(*mem_object),
95+
GFP_KERNEL);
9696
if (!mem_object)
9797
return -ENOMEM;
9898

0 commit comments

Comments
 (0)