Skip to content

Commit 1c05d9a

Browse files
krzkjenswi-linaro
authored andcommitted
tee: qcomtee: user: 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 7c4c14a commit 1c05d9a

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/tee/qcomtee/user_obj.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@ static int qcomtee_user_object_dispatch(struct qcomtee_object_invoke_ctx *oic,
228228
{
229229
struct qcomtee_user_object *uo = to_qcomtee_user_object(object);
230230
struct qcomtee_context_data *ctxdata = uo->ctx->data;
231-
struct qcomtee_ureq *ureq __free(kfree) = NULL;
232231
int errno;
233232

234-
ureq = kzalloc(sizeof(*ureq), GFP_KERNEL);
233+
struct qcomtee_ureq *ureq __free(kfree) = kzalloc(sizeof(*ureq),
234+
GFP_KERNEL);
235235
if (!ureq)
236236
return -ENOMEM;
237237

@@ -367,10 +367,10 @@ int qcomtee_user_param_to_object(struct qcomtee_object **object,
367367
struct tee_param *param,
368368
struct tee_context *ctx)
369369
{
370-
struct qcomtee_user_object *user_object __free(kfree) = NULL;
371370
int err;
372371

373-
user_object = kzalloc(sizeof(*user_object), GFP_KERNEL);
372+
struct qcomtee_user_object *user_object __free(kfree) =
373+
kzalloc(sizeof(*user_object), GFP_KERNEL);
374374
if (!user_object)
375375
return -ENOMEM;
376376

0 commit comments

Comments
 (0)