Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame] | 1 | From 9f3b899a2e8bf79f572f408bfd86836578f46106 Mon Sep 17 00:00:00 2001 |
| 2 | From: Lv Ruyi <lv.ruyi@zte.com.cn> |
| 3 | Date: Thu, 4 Nov 2021 11:30:47 +0000 |
| 4 | Subject: [PATCH 15/40] optee: fix kfree NULL pointer |
| 5 | |
| 6 | This patch fixes the following Coccinelle error: |
| 7 | drivers/tee/optee/ffa_abi.c: 877: ERROR optee is NULL but dereferenced. |
| 8 | |
| 9 | If memory allocation fails, optee is null pointer. the code will goto err |
| 10 | and release optee. |
| 11 | |
| 12 | Fixes: 4615e5a34b95 ("optee: add FF-A support") |
| 13 | Reported-by: Zeal Robot <zealci@zte.com.cn> |
| 14 | Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn> |
| 15 | Reviewed-by: Sumit Garg <sumit.garg@linaro.org> |
| 16 | [jw: removed the redundant braces] |
| 17 | Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> |
Andrew Geissler | 2daf84b | 2023-03-31 09:57:23 -0500 | [diff] [blame^] | 18 | Upstream-Status: Backport [c23ca66a4dadb6f050dc57358bc8d57a747c35bf] |
Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame] | 19 | Signed-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 | |
| 24 | diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c |
| 25 | index 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 | -- |
| 43 | 2.34.1 |
| 44 | |