]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
optee: ffa: Add NULL check in optee_ffa_lend_protmem
authorMostafa Saleh <smostafa@google.com>
Wed, 17 Jun 2026 14:51:24 +0000 (14:51 +0000)
committerJens Wiklander <jenswi@kernel.org>
Mon, 29 Jun 2026 06:04:45 +0000 (08:04 +0200)
Sashiko (locally) reports a possible null dereference under memory
pressure due to the lack of validation of the allocated pointer.

Fix that by adding the missing check.

Fixes: 2b78d79cdf96 ("optee: FF-A: dynamic protected memory allocation")
Signed-off-by: Mostafa Saleh <smostafa@google.com>
Signed-off-by: Sebastian Ene <sebastianene@google.com>
Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Reviewed-by: Sebastian Ene <sebastianene@google.com>
Signed-off-by: Jens Wiklander <jenswi@kernel.org>
drivers/tee/optee/ffa_abi.c

index b4372fa268d032126539a59b076493cc9c2a6a62..633715b98625cdeb578fbadf514c5ac5b9558cef 100644 (file)
@@ -698,6 +698,9 @@ static int optee_ffa_lend_protmem(struct optee *optee, struct tee_shm *protmem,
        int rc;
 
        mem_attr = kzalloc_objs(*mem_attr, ma_count);
+       if (!mem_attr)
+               return -ENOMEM;
+
        for (n = 0; n < ma_count; n++) {
                mem_attr[n].receiver = mem_attrs[n] & U16_MAX;
                mem_attr[n].attrs = mem_attrs[n] >> 16;