diff options
author | Lv Ruyi <lv.ruyi@zte.com.cn> | 2021-11-04 12:30:47 +0100 |
---|---|---|
committer | Jens Wiklander <jens.wiklander@linaro.org> | 2021-11-16 14:41:23 +0100 |
commit | c23ca66a4dadb6f050dc57358bc8d57a747c35bf (patch) | |
tree | a92cf2ea31b95e50fc1be378bfe366cb2d2f94f4 /drivers/tee | |
parent | Linux 5.16-rc1 (diff) | |
download | linux-c23ca66a4dadb6f050dc57358bc8d57a747c35bf.tar.xz linux-c23ca66a4dadb6f050dc57358bc8d57a747c35bf.zip |
optee: fix kfree NULL pointer
This patch fixes the following Coccinelle error:
drivers/tee/optee/ffa_abi.c: 877: ERROR optee is NULL but dereferenced.
If memory allocation fails, optee is null pointer. the code will goto err
and release optee.
Fixes: 4615e5a34b95 ("optee: add FF-A support")
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
[jw: removed the redundant braces]
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Diffstat (limited to 'drivers/tee')
-rw-r--r-- | drivers/tee/optee/ffa_abi.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c index 45424824e0f9..d8c8683863aa 100644 --- a/drivers/tee/optee/ffa_abi.c +++ b/drivers/tee/optee/ffa_abi.c @@ -810,10 +810,9 @@ static int optee_ffa_probe(struct ffa_device *ffa_dev) return -EINVAL; optee = kzalloc(sizeof(*optee), GFP_KERNEL); - if (!optee) { - rc = -ENOMEM; - goto err; - } + if (!optee) + return -ENOMEM; + optee->pool = optee_ffa_config_dyn_shm(); if (IS_ERR(optee->pool)) { rc = PTR_ERR(optee->pool); |