Skip to content

Commit 4cc1951

Browse files
krzkjenswi-linaro
authored andcommitted
tee: qcomtee: call: 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 8f0b4cc commit 4cc1951

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

drivers/tee/qcomtee/call.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,7 @@ static int qcomtee_object_invoke(struct tee_context *ctx,
395395
struct tee_ioctl_object_invoke_arg *arg,
396396
struct tee_param *params)
397397
{
398-
struct qcomtee_object_invoke_ctx *oic __free(kfree) = NULL;
399398
struct qcomtee_context_data *ctxdata = ctx->data;
400-
struct qcomtee_arg *u __free(kfree) = NULL;
401399
struct qcomtee_object *object;
402400
int i, ret, result;
403401

@@ -412,12 +410,14 @@ static int qcomtee_object_invoke(struct tee_context *ctx,
412410
}
413411

414412
/* Otherwise, invoke a QTEE object: */
415-
oic = qcomtee_object_invoke_ctx_alloc(ctx);
413+
struct qcomtee_object_invoke_ctx *oic __free(kfree) =
414+
qcomtee_object_invoke_ctx_alloc(ctx);
416415
if (!oic)
417416
return -ENOMEM;
418417

419418
/* +1 for ending QCOMTEE_ARG_TYPE_INV. */
420-
u = kcalloc(arg->num_params + 1, sizeof(*u), GFP_KERNEL);
419+
struct qcomtee_arg *u __free(kfree) = kcalloc(arg->num_params + 1, sizeof(*u),
420+
GFP_KERNEL);
421421
if (!u)
422422
return -ENOMEM;
423423

@@ -562,9 +562,8 @@ static int qcomtee_supp_send(struct tee_context *ctx, u32 errno, u32 num_params,
562562

563563
static int qcomtee_open(struct tee_context *ctx)
564564
{
565-
struct qcomtee_context_data *ctxdata __free(kfree) = NULL;
566-
567-
ctxdata = kzalloc(sizeof(*ctxdata), GFP_KERNEL);
565+
struct qcomtee_context_data *ctxdata __free(kfree) = kzalloc(sizeof(*ctxdata),
566+
GFP_KERNEL);
568567
if (!ctxdata)
569568
return -ENOMEM;
570569

@@ -645,12 +644,12 @@ static void qcomtee_get_version(struct tee_device *teedev,
645644
static void qcomtee_get_qtee_feature_list(struct tee_context *ctx, u32 id,
646645
u32 *version)
647646
{
648-
struct qcomtee_object_invoke_ctx *oic __free(kfree) = NULL;
649647
struct qcomtee_object *client_env, *service;
650648
struct qcomtee_arg u[3] = { 0 };
651649
int result;
652650

653-
oic = qcomtee_object_invoke_ctx_alloc(ctx);
651+
struct qcomtee_object_invoke_ctx *oic __free(kfree) =
652+
qcomtee_object_invoke_ctx_alloc(ctx);
654653
if (!oic)
655654
return;
656655

0 commit comments

Comments
 (0)