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>
struct tee_param *param,
struct tee_context *ctx)
{
- struct qcomtee_mem_object *mem_object __free(kfree) = NULL;
struct tee_shm *shm;
int err;
- mem_object = kzalloc(sizeof(*mem_object), GFP_KERNEL);
+ struct qcomtee_mem_object *mem_object __free(kfree) = kzalloc(sizeof(*mem_object),
+ GFP_KERNEL);
if (!mem_object)
return -ENOMEM;