blob: 090ff3bea09108af8921efb4940f0213b523b897 [file] [log] [blame]
Patrick Williams2194f502022-10-16 14:26:09 -05001From 9f3b899a2e8bf79f572f408bfd86836578f46106 Mon Sep 17 00:00:00 2001
2From: Lv Ruyi <lv.ruyi@zte.com.cn>
3Date: Thu, 4 Nov 2021 11:30:47 +0000
4Subject: [PATCH 15/40] optee: fix kfree NULL pointer
5
6This patch fixes the following Coccinelle error:
7drivers/tee/optee/ffa_abi.c: 877: ERROR optee is NULL but dereferenced.
8
9If memory allocation fails, optee is null pointer. the code will goto err
10and release optee.
11
12Fixes: 4615e5a34b95 ("optee: add FF-A support")
13Reported-by: Zeal Robot <zealci@zte.com.cn>
14Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
15Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
16[jw: removed the redundant braces]
17Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Andrew Geissler2daf84b2023-03-31 09:57:23 -050018Upstream-Status: Backport [c23ca66a4dadb6f050dc57358bc8d57a747c35bf]
Patrick Williams2194f502022-10-16 14:26:09 -050019Signed-off-by: Rupinderjit Singh <rupinderjit.singh@arm.com
20---
21 drivers/tee/optee/ffa_abi.c | 7 +++----
22 1 file changed, 3 insertions(+), 4 deletions(-)
23
24diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
25index 45424824e0f9..d8c8683863aa 100644
26--- a/drivers/tee/optee/ffa_abi.c
27+++ b/drivers/tee/optee/ffa_abi.c
28@@ -810,10 +810,9 @@ static int optee_ffa_probe(struct ffa_device *ffa_dev)
29 return -EINVAL;
30
31 optee = kzalloc(sizeof(*optee), GFP_KERNEL);
32- if (!optee) {
33- rc = -ENOMEM;
34- goto err;
35- }
36+ if (!optee)
37+ return -ENOMEM;
38+
39 optee->pool = optee_ffa_config_dyn_shm();
40 if (IS_ERR(optee->pool)) {
41 rc = PTR_ERR(optee->pool);
42--
432.34.1
44